Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
c08f7c0
fix(client): avoid memory leak with abort signals
stainless-app[bot] Feb 2, 2026
4b5fcbf
chore(client): do not parse responses with empty content-length
stainless-app[bot] Feb 2, 2026
5f6c688
chore(internal): support oauth authorization code flow for MCP servers
stainless-app[bot] Feb 3, 2026
46c04e1
chore(client): restructure abort controller binding
stainless-app[bot] Feb 4, 2026
ff4b97e
chore(internal): refactor flag parsing for MCP servers and add debug …
stainless-app[bot] Feb 4, 2026
cdce131
feat(mcp): add initial server instructions
stainless-app[bot] Feb 4, 2026
0738e88
fix(client): avoid removing abort listener too early
stainless-app[bot] Feb 5, 2026
83d1174
chore(internal): add health check to MCP server when running in HTTP …
stainless-app[bot] Feb 6, 2026
61a5d88
chore(internal): upgrade hono
stainless-app[bot] Feb 6, 2026
90eae18
chore(internal): always generate MCP server dockerfiles and upgrade a…
stainless-app[bot] Feb 9, 2026
4a86182
chore(internal): allow basic filtering of methods allowed for MCP cod…
stainless-app[bot] Feb 9, 2026
7cd3980
chore(internal): avoid type checking errors with ts-reset
stainless-app[bot] Feb 11, 2026
bf91d73
chore(mcp): forward STAINLESS_API_KEY to docs search endpoint
stainless-app[bot] Feb 13, 2026
b2e0a75
chore(internal): improve layout of generated MCP server files
stainless-app[bot] Feb 13, 2026
d96f483
chore(internal/client): fix form-urlencoded requests
stainless-app[bot] Feb 17, 2026
a72133c
chore(internal): allow setting x-stainless-api-key header on mcp serv…
stainless-app[bot] Feb 17, 2026
7738ab8
chore(internal): cache fetch instruction calls in MCP server
stainless-app[bot] Feb 18, 2026
66c5305
fix(mcp): initialize SDK lazily to avoid failing the connection on in…
stainless-app[bot] Feb 19, 2026
f1deef8
chore(internal): remove mock server code
stainless-app[bot] Feb 19, 2026
8d9ad04
chore: update mock server docs
stainless-app[bot] Feb 19, 2026
57fa966
chore(mcp): correctly update version in sync with sdk
stainless-app[bot] Feb 19, 2026
e39e377
chore(internal): update agents version
stainless-app[bot] Feb 23, 2026
743a112
fix(docs/contributing): correct pnpm link command
stainless-app[bot] Feb 23, 2026
446fc85
chore(internal): upgrade @modelcontextprotocol/sdk and hono
stainless-app[bot] Feb 23, 2026
4178900
chore(internal): codegen related update
stainless-app[bot] Feb 24, 2026
497c926
chore(internal): make MCP code execution location configurable via a …
stainless-app[bot] Feb 24, 2026
62b9ad0
chore(internal): fix MCP Dockerfiles so they can be built without bui…
stainless-app[bot] Feb 25, 2026
acd6e59
release: 7.4.0
stainless-app[bot] Feb 25, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Dependencies
node_modules/
**/node_modules/

# Build outputs
dist/
**/dist/

# Git
.git/
.gitignore

# CI/CD
.github/
.gitlab-ci.yml
.travis.yml

# IDE
.vscode/
.idea/
*.swp
*.swo
*~

# OS
.DS_Store
Thumbs.db

# Testing
test/
tests/
__tests__/
*.test.js
*.spec.js
coverage/
.nyc_output/

# Logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Environment
.env
.env.*

# Temporary files
*.tmp
*.temp
.cache/

# Examples and scripts
examples/
bin/

# Other packages (we only need mcp-server)
packages/*/
!packages/mcp-server/
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "7.3.0"
".": "7.4.0"
}
42 changes: 42 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,47 @@
# Changelog

## 7.4.0 (2026-02-25)

Full Changelog: [v7.3.0...v7.4.0](https://github.com/imagekit-developer/imagekit-nodejs/compare/v7.3.0...v7.4.0)

### Features

* **mcp:** add initial server instructions ([cdce131](https://github.com/imagekit-developer/imagekit-nodejs/commit/cdce131dc17fba5469393a285ac536acd74742b2))


### Bug Fixes

* **client:** avoid memory leak with abort signals ([c08f7c0](https://github.com/imagekit-developer/imagekit-nodejs/commit/c08f7c04267e000d51cfad22ec8337e456d20171))
* **client:** avoid removing abort listener too early ([0738e88](https://github.com/imagekit-developer/imagekit-nodejs/commit/0738e8884a59ddac579fab6a65e0221fdff4247c))
* **docs/contributing:** correct pnpm link command ([743a112](https://github.com/imagekit-developer/imagekit-nodejs/commit/743a1126b13d90832ccac545474eda7a1094043f))
* **mcp:** initialize SDK lazily to avoid failing the connection on init errors ([66c5305](https://github.com/imagekit-developer/imagekit-nodejs/commit/66c53054ce63794350a9939b8f38ecea3ddec428))


### Chores

* **client:** do not parse responses with empty content-length ([4b5fcbf](https://github.com/imagekit-developer/imagekit-nodejs/commit/4b5fcbfd1188573ccd1cea40b8e4924a5e2051dc))
* **client:** restructure abort controller binding ([46c04e1](https://github.com/imagekit-developer/imagekit-nodejs/commit/46c04e16c46bca7bc1b0383d151f027d7d918611))
* **internal/client:** fix form-urlencoded requests ([d96f483](https://github.com/imagekit-developer/imagekit-nodejs/commit/d96f4832db9e8c16cbeae32f9a7eb46234bb64ed))
* **internal:** add health check to MCP server when running in HTTP mode ([83d1174](https://github.com/imagekit-developer/imagekit-nodejs/commit/83d1174751241a66748b9d0f4b2b92f37715d4ad))
* **internal:** allow basic filtering of methods allowed for MCP code mode ([4a86182](https://github.com/imagekit-developer/imagekit-nodejs/commit/4a861827d463d2b6e9812a4aa58d2df14cb356bf))
* **internal:** allow setting x-stainless-api-key header on mcp server requests ([a72133c](https://github.com/imagekit-developer/imagekit-nodejs/commit/a72133c81d0f9ad9587793bb92c06963fce21e8e))
* **internal:** always generate MCP server dockerfiles and upgrade associated dependencies ([90eae18](https://github.com/imagekit-developer/imagekit-nodejs/commit/90eae18e29708d7596a6e783cad196c9a4f75f39))
* **internal:** avoid type checking errors with ts-reset ([7cd3980](https://github.com/imagekit-developer/imagekit-nodejs/commit/7cd398067ad0736b67bfb3d8ace58d15a94c1fd2))
* **internal:** cache fetch instruction calls in MCP server ([7738ab8](https://github.com/imagekit-developer/imagekit-nodejs/commit/7738ab86d47fbca9a3c05c2cd48910d43d557c43))
* **internal:** codegen related update ([4178900](https://github.com/imagekit-developer/imagekit-nodejs/commit/41789006a0bdd72bf302bea9c493efcca5927f5d))
* **internal:** fix MCP Dockerfiles so they can be built without buildkit ([62b9ad0](https://github.com/imagekit-developer/imagekit-nodejs/commit/62b9ad0590c40c17cfcd1e7a68f2d5b2b6171cd1))
* **internal:** improve layout of generated MCP server files ([b2e0a75](https://github.com/imagekit-developer/imagekit-nodejs/commit/b2e0a75d79757596569d0277467ccad531d49bdd))
* **internal:** make MCP code execution location configurable via a flag ([497c926](https://github.com/imagekit-developer/imagekit-nodejs/commit/497c9269a3438a872c1ddb7a213d34abe90d6f6b))
* **internal:** refactor flag parsing for MCP servers and add debug flag ([ff4b97e](https://github.com/imagekit-developer/imagekit-nodejs/commit/ff4b97e40fb46ca0b4f3229074c3f614b045641c))
* **internal:** remove mock server code ([f1deef8](https://github.com/imagekit-developer/imagekit-nodejs/commit/f1deef8b69950e5917919a9fc619b558a65fe5b7))
* **internal:** support oauth authorization code flow for MCP servers ([5f6c688](https://github.com/imagekit-developer/imagekit-nodejs/commit/5f6c688f4f41df60d88fce94bc10cfdce4e29d78))
* **internal:** update agents version ([e39e377](https://github.com/imagekit-developer/imagekit-nodejs/commit/e39e3777d9d0ccd225774c2a889aa6b6c81a6402))
* **internal:** upgrade @modelcontextprotocol/sdk and hono ([446fc85](https://github.com/imagekit-developer/imagekit-nodejs/commit/446fc85863574d74d94918ee09aff23f4ed373b4))
* **internal:** upgrade hono ([61a5d88](https://github.com/imagekit-developer/imagekit-nodejs/commit/61a5d8863e4fcb692d187bb0a7b44e1788faf8ee))
* **mcp:** correctly update version in sync with sdk ([57fa966](https://github.com/imagekit-developer/imagekit-nodejs/commit/57fa966d57b1069c554658921a3d649a563e4e12))
* **mcp:** forward STAINLESS_API_KEY to docs search endpoint ([bf91d73](https://github.com/imagekit-developer/imagekit-nodejs/commit/bf91d7300f134a716038b00bbdcf0cd5932176ea))
* update mock server docs ([8d9ad04](https://github.com/imagekit-developer/imagekit-nodejs/commit/8d9ad04f864ca543a065a99cc041a436dd53069a))

## 7.3.0 (2026-02-02)

Full Changelog: [v7.2.2...v7.3.0](https://github.com/imagekit-developer/imagekit-nodejs/compare/v7.2.2...v7.3.0)
Expand Down
8 changes: 1 addition & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,11 @@ $ yarn link @imagekit/nodejs
# With pnpm
$ pnpm link --global
$ cd ../my-package
$ pnpm link -global @imagekit/nodejs
$ pnpm link --global @imagekit/nodejs
```

## Running tests

Most tests require you to [set up a mock server](https://github.com/stoplightio/prism) against the OpenAPI spec to run the tests.

```sh
$ npx prism mock path/to/your/openapi.yml
```

```sh
$ yarn run test
```
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@imagekit/nodejs",
"version": "7.3.0",
"version": "7.4.0",
"description": "Offical NodeJS SDK for ImageKit.io integration",
"author": "Image Kit <developer@imagekit.io>",
"types": "dist/index.d.ts",
Expand Down
83 changes: 83 additions & 0 deletions packages/mcp-server/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Dockerfile for Image Kit MCP Server
#
# This Dockerfile builds a Docker image for the MCP Server.
#
# To build the image locally:
# docker build -f packages/mcp-server/Dockerfile -t @imagekit/api-mcp:local .
#
# To run the image:
# docker run -i @imagekit/api-mcp:local [OPTIONS]
#
# Common options:
# --tool=<name> Include specific tools
# --resource=<name> Include tools for specific resources
# --operation=read|write Filter by operation type
# --client=<type> Set client compatibility (e.g., claude, cursor)
# --transport=<type> Set transport type (stdio or http)
#
# For a full list of options:
# docker run -i @imagekit/api-mcp:local --help
#
# Note: The MCP server uses stdio transport by default. Docker's -i flag
# enables interactive mode, allowing the container to communicate over stdin/stdout.

# Build stage
FROM node:24-alpine AS builder

# Install bash for build script
RUN apk add --no-cache bash openssl

# Set working directory
WORKDIR /build

# Copy entire repository
COPY . .

# Install all dependencies and build everything
RUN yarn install --frozen-lockfile && \
yarn build

FROM denoland/deno:bin-2.6.10 AS deno_installer
FROM gcr.io/distroless/cc@sha256:66d87e170bc2c5e2b8cf853501141c3c55b4e502b8677595c57534df54a68cc5 AS cc

FROM node:24-alpine

# Install deno
COPY --from=deno_installer /deno /usr/local/bin/deno

# Add in shared libraries needed by Deno
COPY --from=cc /lib/*-linux-gnu/* /usr/local/lib/
COPY --from=cc /lib/ld-linux-* /lib/

RUN mkdir /lib64 && ln -s /usr/local/lib/ld-linux-* /lib64/
ENV LD_LIBRARY_PATH=/usr/lib:/usr/local/lib

# Add non-root user
RUN addgroup -g 1001 -S nodejs && adduser -S nodejs -u 1001

# Set working directory
WORKDIR /app

# Copy the built mcp-server dist directory
COPY --from=builder /build/packages/mcp-server/dist ./

# Copy node_modules from mcp-server (includes all production deps)
COPY --from=builder /build/packages/mcp-server/node_modules ./node_modules

# Copy the built @imagekit/nodejs into node_modules
COPY --from=builder /build/dist ./node_modules/@imagekit/nodejs

# Change ownership to nodejs user
RUN chown -R nodejs:nodejs /app

# Switch to non-root user
USER nodejs

# The MCP server uses stdio transport by default
# No exposed ports needed for stdio communication

# Set the entrypoint to the MCP server
ENTRYPOINT ["node", "index.js"]

# Allow passing arguments to the MCP server
CMD []
6 changes: 3 additions & 3 deletions packages/mcp-server/cloudflare-worker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
},
"dependencies": {
"@cloudflare/workers-oauth-provider": "^0.0.5",
"@modelcontextprotocol/sdk": "^1.25.2",
"agents": "^0.0.88",
"hono": "^4.11.4",
"@modelcontextprotocol/sdk": "^1.26.0",
"agents": "^0.0.113",
"hono": "^4.12.2",
"@imagekit/api-mcp": "latest",
"zod": "^3.24.4"
}
Expand Down
10 changes: 7 additions & 3 deletions packages/mcp-server/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"dxt_version": "0.2",
"name": "@imagekit/api-mcp",
"version": "0.0.1-alpha.0",
"version": "7.4.0",
"description": "The official MCP Server for the Image Kit API",
"author": {
"name": "Image Kit",
Expand All @@ -18,7 +18,9 @@
"entry_point": "index.js",
"mcp_config": {
"command": "node",
"args": ["${__dirname}/index.js"],
"args": [
"${__dirname}/index.js"
],
"env": {
"IMAGEKIT_PRIVATE_KEY": "${user_config.IMAGEKIT_PRIVATE_KEY}",
"OPTIONAL_IMAGEKIT_IGNORES_THIS": "${user_config.OPTIONAL_IMAGEKIT_IGNORES_THIS}",
Expand Down Expand Up @@ -53,5 +55,7 @@
"node": ">=18.0.0"
}
},
"keywords": ["api"]
"keywords": [
"api"
]
}
9 changes: 7 additions & 2 deletions packages/mcp-server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@imagekit/api-mcp",
"version": "7.3.0",
"version": "7.4.0",
"description": "The official MCP Server for the Image Kit API",
"author": "Image Kit <developer@imagekit.io>",
"types": "dist/index.d.ts",
Expand Down Expand Up @@ -32,12 +32,15 @@
"dependencies": {
"@imagekit/nodejs": "file:../../dist/",
"@cloudflare/cabidela": "^0.2.4",
"@modelcontextprotocol/sdk": "^1.25.2",
"@modelcontextprotocol/sdk": "^1.26.0",
"@valtown/deno-http-worker": "^0.0.21",
"cookie-parser": "^1.4.6",
"cors": "^2.8.5",
"express": "^5.1.0",
"fuse.js": "^7.1.0",
"jq-web": "https://github.com/stainless-api/jq-web/releases/download/v0.8.8/jq-web.tar.gz",
"morgan": "^1.10.0",
"morgan-body": "^2.6.9",
"qs": "^6.14.1",
"typescript": "5.8.3",
"yargs": "^17.7.2",
Expand All @@ -50,9 +53,11 @@
},
"devDependencies": {
"@anthropic-ai/mcpb": "^2.1.2",
"@types/cookie-parser": "^1.4.10",
"@types/cors": "^2.8.19",
"@types/express": "^5.0.3",
"@types/jest": "^29.4.0",
"@types/morgan": "^1.9.10",
"@types/qs": "^6.14.0",
"@types/yargs": "^17.0.8",
"@typescript-eslint/eslint-plugin": "8.31.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

import { IncomingMessage } from 'node:http';
import { ClientOptions } from '@imagekit/nodejs';
import { McpOptions } from './options';

export const parseAuthHeaders = (req: IncomingMessage): Partial<ClientOptions> => {
export const parseClientAuthHeaders = (req: IncomingMessage, required?: boolean): Partial<ClientOptions> => {
if (req.headers.authorization) {
const scheme = req.headers.authorization.split(' ')[0]!;
const value = req.headers.authorization.slice(scheme.length + 1);
Expand All @@ -19,6 +20,8 @@ export const parseAuthHeaders = (req: IncomingMessage): Partial<ClientOptions> =
'Unsupported authorization scheme. Expected the "Authorization" header to be a supported scheme (Basic).',
);
}
} else if (required) {
throw new Error('Missing required Authorization header; see WWW-Authenticate header for details.');
}

const privateKey =
Expand All @@ -31,3 +34,17 @@ export const parseAuthHeaders = (req: IncomingMessage): Partial<ClientOptions> =
: req.headers['x-optional-imagekit-ignores-this'];
return { privateKey, password };
};

export const getStainlessApiKey = (req: IncomingMessage, mcpOptions: McpOptions): string | undefined => {
// Try to get the key from the x-stainless-api-key header
const headerKey =
Array.isArray(req.headers['x-stainless-api-key']) ?
req.headers['x-stainless-api-key'][0]
: req.headers['x-stainless-api-key'];
if (headerKey && typeof headerKey === 'string') {
return headerKey;
}

// Fall back to value set in the mcpOptions (e.g. from environment variable), if provided
return mcpOptions.stainlessApiKey;
};
3 changes: 3 additions & 0 deletions packages/mcp-server/src/code-tool-paths.cts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

export const workerPath = require.resolve('./code-tool-worker.mjs');
1 change: 1 addition & 0 deletions packages/mcp-server/src/code-tool-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export type WorkerInput = {
client_opts: ClientOptions;
intent?: string | undefined;
};

export type WorkerOutput = {
is_error: boolean;
result: unknown | null;
Expand Down
Loading