@mythrex/api-mcp-temp
v7.7.2-test.1
Published
The official MCP Server for the Image Kit API
Readme
ImageKit API MCP Server (Developer Guide)
This repository hosts the ImageKit MCP server implementation used to expose ImageKit capabilities to MCP clients (VS Code, Cursor, Claude Code, and other compliant clients).
The server supports two runtime modes:
- Local stdio MCP server for direct client integration.
- Remote HTTP MCP server with built-in OAuth 2.0 for multi-user deployments (for example EKS).
What Is MCP And What This Server Does
MCP (Model Context Protocol) is a standard way for LLM clients to call tools.
This server provides ImageKit operations through two MCP tools:
- search_docs
- execute
The common flow is:
- Agent calls search_docs to discover the right SDK methods.
- Agent calls execute with TypeScript code.
- Server runs that code in an isolated Deno worker with an initialized ImageKit SDK client.
- Worker output is returned as MCP tool result.
Repository Overview
src/index.ts: entrypoint and transport selection.src/http.ts: HTTP transport, OAuth endpoints, bearer-token validation, MCP route handling.src/stdio.ts: stdio transport launcher.src/server.ts: MCP tool registration and request handlers.src/code-tool.ts: execute tool implementation (sandboxed code execution).src/docs-search-tool.ts: search_docs tool implementation (local docs index).src/oauth-store.ts: OAuth storage abstraction, in-memory store, Redis store.src/options.ts: CLI flags and env parsing.helm-chart/: Kubernetes chart for EKS-style deployments..github/workflows/cd.yaml: CI/CD workflow (build, push, helm deploy).
Tools Exposed
search_docs
- Purpose: Search SDK documentation and examples.
- Input:
query,language, optionaldetail. - Behavior: Read-only local docs search.
execute
- Purpose: Execute TypeScript code against initialized
@imagekit/nodejsclient. - Input:
code, optionalintent. - Behavior:
- Runs code in a Deno worker.
- Network egress is constrained to ImageKit API host.
- Returns console output and function return value.
- Can block configured SDK methods.
Authentication And Credential Model
The server supports two auth models in HTTP mode:
- OAuth 2.0 Authorization Code + PKCE (default, recommended for remote clients).
- Legacy direct credential headers or environment variable.
OAuth Endpoints
POST /registerGET /authorizePOST /approvePOST /tokenGET /.well-known/oauth-authorization-serverGET /.well-known/oauth-protected-resource
Aliases are also exposed under /mcp/.well-known/* to support clients expecting MCP-scoped metadata.
Credential Handling
At approval time, user enters ImageKit private key (and optional password). The server stores these in OAuth records and, on authenticated requests, hydrates request headers internally for SDK calls.
Store Behavior: Memory Vs Redis
- No
REDIS_URL: in-memory store (InMemoryOAuthStore), suitable for local development/single-process use. - With
REDIS_URL: Redis-backed store (RedisOAuthStore), required for stable multi-pod or restart-safe deployments.
TTL Logic
- Authorization code TTL: 300 seconds (5 minutes).
- Access token TTL: configurable.
- Default code fallback: 86400 seconds.
- Recommended deployment override:
OAUTH_ACCESS_TOKEN_TTL_SECONDS(for example 2592000 = 30 days).
Issuer URL Behavior (Important For Ingress)
Issuer/base URL is resolved in this order:
OAUTH_ISSUERif explicitly set.- Forwarded ingress headers (
X-Forwarded-Proto,X-Forwarded-Host). - Request protocol + host.
This allows one image/chart to run across different exposed domains without hardcoding issuer in most ingress setups.
Running Locally
Prerequisites
- Node.js 20+.
- npm.
- Deno installed (required by execute tool).
- Optional: Redis (for OAuth persistence across restarts).
Install And Build
npm ci
npm run buildRun As Stdio MCP Server
export IMAGEKIT_PRIVATE_KEY="<your_private_key>"
node dist/index.js --transport stdioRun As Remote HTTP MCP Server (OAuth enabled)
node dist/index.js \
--transport http \
--port 3001 \
--redis-url redis://localhost:6379Optional runtime env:
OAUTH_ACCESS_TOKEN_TTL_SECONDS=2592000OAUTH_ISSUER=https://your-public-domain(usually not required if forwarded headers are correct)
Quick Local Health Checks
curl http://localhost:3001/health
curl http://localhost:3001/.well-known/oauth-authorization-server
curl -X POST http://localhost:3001/mcp -H 'content-type: application/json' -d '{}'The last request should return the auth HTML when unauthenticated.
Running On Kubernetes (Helm)
Chart
- Chart path:
helm-chart/ - Service name:
imagekit-api-mcp-server-service
Deploy
helm upgrade imagekit-api-mcp-server ./helm-chart --installCommon production values:
- Image repository/tag.
- Redis host/port.
env.OAUTH_ACCESS_TOKEN_TTL_SECONDS.- Resource requests/limits.
Development Notes
- Build script:
npm run build(uses./build). - Tests:
npm test. - Lint:
npm run lint. - HTTP default option in CLI is port 3000, but repo deployment examples commonly use 3001.
Security Notes
- Use Redis in real deployments. In-memory OAuth store is not restart-safe.
- Keep token TTL aligned with security requirements. Longer TTL reduces login prompts but increases token exposure window.
- Prefer OAuth over static private-key env for multi-user remote access.
- If deploying behind ingress, ensure forwarded headers are preserved.
CI/CD
The workflow in .github/workflows/cd.yaml is adapted for this repository and performs:
- Node build/test.
- Docker image build and push to ECR.
- Helm deploy to stage/prod EKS clusters using repo variables/secrets.
