Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.22.1"
".": "0.22.2"
}
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
# Changelog

## 0.22.2 (2026-04-13)

Full Changelog: [v0.22.1...v0.22.2](https://github.com/isaacus-dev/isaacus-typescript/compare/v0.22.1...v0.22.2)

### Chores

* **internal:** codegen related update ([cd5ec86](https://github.com/isaacus-dev/isaacus-typescript/commit/cd5ec86a820fbac4520158b5fae003a6599fefc0))
* **internal:** codegen related update ([e862e90](https://github.com/isaacus-dev/isaacus-typescript/commit/e862e90b1f033b392912960f942d40fc383ce105))
* **internal:** fix MCP docker image builds in yarn projects ([1bae689](https://github.com/isaacus-dev/isaacus-typescript/commit/1bae68900a33b2493aab475da4ab3b2b29df7107))
* **internal:** fix MCP server import ordering ([f6e97bb](https://github.com/isaacus-dev/isaacus-typescript/commit/f6e97bbf7d651a7de7144059598e81bd625fb592))
* **internal:** improve local docs search for MCP servers ([a75ecde](https://github.com/isaacus-dev/isaacus-typescript/commit/a75ecdeaa324f978296b0bff15dd1cb025826cea))
* **internal:** improve local docs search for MCP servers ([04d3e6d](https://github.com/isaacus-dev/isaacus-typescript/commit/04d3e6d50fb40450008b888f47c0337a964bee83))
* **internal:** show error causes in MCP servers when running in local mode ([fa77f22](https://github.com/isaacus-dev/isaacus-typescript/commit/fa77f220e93b435a3b7ad0ad37b9f5158e4e7bba))
* **internal:** support type annotations when running MCP in local execution mode ([54d9001](https://github.com/isaacus-dev/isaacus-typescript/commit/54d90010c7f02e93aebbbb0d577d47f8557f5933))
* **internal:** use link instead of file in MCP server package.json files ([670add9](https://github.com/isaacus-dev/isaacus-typescript/commit/670add93de484bd49d49dcd03c3d5bc3581d2021))
* **mcp-server:** add support for session id, forward client info ([113e23c](https://github.com/isaacus-dev/isaacus-typescript/commit/113e23c3565fd8f4c39dc54e5ccb77216b3230f5))
* **mcp-server:** increase local docs search result count from 5 to 10 ([2e69ea0](https://github.com/isaacus-dev/isaacus-typescript/commit/2e69ea055862bde72ba63d47eb769a9a7750e079))
* **mcp-server:** log client info ([823adba](https://github.com/isaacus-dev/isaacus-typescript/commit/823adbac413f484a67e00354e5284e89479b71da))


### Documentation

* update examples ([e668eb8](https://github.com/isaacus-dev/isaacus-typescript/commit/e668eb823f4bcd59c96bc62a232f1d608a7ff9f3))

## 0.22.1 (2026-03-28)

Full Changelog: [v0.22.0...v0.22.1](https://github.com/isaacus-dev/isaacus-typescript/compare/v0.22.0...v0.22.1)
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": "isaacus",
"version": "0.22.1",
"version": "0.22.2",
"description": "The official TypeScript library for the Isaacus API",
"author": "Isaacus <support@isaacus.com>",
"types": "dist/index.d.ts",
Expand Down
4 changes: 3 additions & 1 deletion packages/mcp-server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ COPY . .

# Install all dependencies and build everything
RUN yarn install --frozen-lockfile && \
yarn build
yarn build && \
# Remove the symlink to the SDK so it doesn't interfere with the explicit COPY below
rm -Rf packages/mcp-server/node_modules/isaacus

FROM denoland/deno:alpine-2.7.1

Expand Down
2 changes: 1 addition & 1 deletion packages/mcp-server/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"dxt_version": "0.2",
"name": "isaacus-mcp",
"version": "0.22.1",
"version": "0.22.2",
"description": "The official MCP Server for the Isaacus API",
"author": {
"name": "Isaacus",
Expand Down
4 changes: 2 additions & 2 deletions packages/mcp-server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "isaacus-mcp",
"version": "0.22.1",
"version": "0.22.2",
"description": "The official MCP Server for the Isaacus API",
"author": "Isaacus <support@isaacus.com>",
"types": "dist/index.d.ts",
Expand Down Expand Up @@ -30,7 +30,7 @@
"fix": "eslint --fix ."
},
"dependencies": {
"isaacus": "file:../../dist/",
"isaacus": "link:../../dist/",
"ajv": "^8.18.0",
"@cloudflare/cabidela": "^0.2.4",
"@hono/node-server": "^1.19.10",
Expand Down
15 changes: 12 additions & 3 deletions packages/mcp-server/src/code-tool-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import ts from 'typescript';
import { WorkerOutput } from './code-tool-types';
import { Isaacus, ClientOptions } from 'isaacus';

async function tseval(code: string) {
return import('data:application/typescript;charset=utf-8;base64,' + Buffer.from(code).toString('base64'));
}

function getRunFunctionSource(code: string): {
type: 'declaration' | 'expression';
client: string | undefined;
Expand Down Expand Up @@ -185,7 +189,8 @@ function makeSdkProxy<T extends object>(obj: T, { path, isBelievedBad = false }:

function parseError(code: string, error: unknown): string | undefined {
if (!(error instanceof Error)) return;
const message = error.name ? `${error.name}: ${error.message}` : error.message;
const cause = error.cause instanceof Error ? `: ${error.cause.message}` : '';
const message = error.name ? `${error.name}: ${error.message}${cause}` : `${error.message}${cause}`;
try {
// Deno uses V8; the first "<anonymous>:LINE:COLUMN" is the top of stack.
const lineNumber = error.stack?.match(/<anonymous>:([0-9]+):[0-9]+/)?.[1];
Expand Down Expand Up @@ -241,7 +246,9 @@ const fetch = async (req: Request): Promise<Response> => {

const log_lines: string[] = [];
const err_lines: string[] = [];
const console = {
const originalConsole = globalThis.console;
globalThis.console = {
...originalConsole,
log: (...args: unknown[]) => {
log_lines.push(util.format(...args));
},
Expand All @@ -251,7 +258,7 @@ const fetch = async (req: Request): Promise<Response> => {
};
try {
let run_ = async (client: any) => {};
eval(`${code}\nrun_ = run;`);
run_ = (await tseval(`${code}\nexport default run;`)).default;
const result = await run_(makeSdkProxy(client, { path: ['client'] }));
return Response.json({
is_error: false,
Expand All @@ -269,6 +276,8 @@ const fetch = async (req: Request): Promise<Response> => {
} satisfies WorkerOutput,
{ status: 400, statusText: 'Code execution error' },
);
} finally {
globalThis.console = originalConsole;
}
};

Expand Down
26 changes: 9 additions & 17 deletions packages/mcp-server/src/docs-search-tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,23 +50,14 @@ export function setLocalSearch(search: LocalDocsSearch): void {
_localSearch = search;
}

const SUPPORTED_LANGUAGES = new Set(['http', 'typescript', 'javascript']);

async function searchLocal(args: Record<string, unknown>): Promise<unknown> {
if (!_localSearch) {
throw new Error('Local search not initialized');
}

const query = (args['query'] as string) ?? '';
const language = (args['language'] as string) ?? 'typescript';
const detail = (args['detail'] as string) ?? 'verbose';

if (!SUPPORTED_LANGUAGES.has(language)) {
throw new Error(
`Local docs search only supports HTTP, TypeScript, and JavaScript. Got language="${language}". ` +
`Use --docs-search-mode stainless-api for other languages, or set language to "http", "typescript", or "javascript".`,
);
}
const detail = (args['detail'] as string) ?? 'default';

return _localSearch.search({
query,
Expand All @@ -76,17 +67,18 @@ async function searchLocal(args: Record<string, unknown>): Promise<unknown> {
}).results;
}

async function searchRemote(
args: Record<string, unknown>,
stainlessApiKey: string | undefined,
): Promise<unknown> {
async function searchRemote(args: Record<string, unknown>, reqContext: McpRequestContext): Promise<unknown> {
const body = args as any;
const query = new URLSearchParams(body).toString();

const startTime = Date.now();
const result = await fetch(`${docsSearchURL}?${query}`, {
headers: {
...(stainlessApiKey && { Authorization: stainlessApiKey }),
...(reqContext.stainlessApiKey && { Authorization: reqContext.stainlessApiKey }),
...(reqContext.mcpSessionId && { 'x-stainless-mcp-session-id': reqContext.mcpSessionId }),
...(reqContext.mcpClientInfo && {
'x-stainless-mcp-client-info': JSON.stringify(reqContext.mcpClientInfo),
}),
},
});

Expand All @@ -105,7 +97,7 @@ async function searchRemote(
'Got error response from docs search tool',
);

if (result.status === 404 && !stainlessApiKey) {
if (result.status === 404 && !reqContext.stainlessApiKey) {
throw new Error(
'Could not find docs for this project. You may need to provide a Stainless API key via the STAINLESS_API_KEY environment variable, the --stainless-api-key flag, or the x-stainless-api-key HTTP header.',
);
Expand Down Expand Up @@ -140,7 +132,7 @@ export const handler = async ({
return asTextContentResult(await searchLocal(body));
}

return asTextContentResult(await searchRemote(body, reqContext.stainlessApiKey));
return asTextContentResult(await searchRemote(body, reqContext));
};

export default { metadata, tool, handler };
25 changes: 25 additions & 0 deletions packages/mcp-server/src/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ const newServer = async ({
}
}

const mcpClientInfo =
typeof req.body?.params?.clientInfo?.name === 'string' ?
{ name: req.body.params.clientInfo.name, version: String(req.body.params.clientInfo.version ?? '') }
: undefined;

await initMcpServer({
server: server,
mcpOptions: effectiveMcpOptions,
Expand All @@ -78,8 +83,14 @@ const newServer = async ({
},
stainlessApiKey: stainlessApiKey,
upstreamClientEnvs,
mcpSessionId: (req as any).mcpSessionId,
mcpClientInfo,
});

if (mcpClientInfo) {
getLogger().info({ mcpSessionId: (req as any).mcpSessionId, mcpClientInfo }, 'MCP client connected');
}

return server;
};

Expand Down Expand Up @@ -135,9 +146,23 @@ export const streamableHTTPApp = ({
const app = express();
app.set('query parser', 'extended');
app.use(express.json());
app.use((req: express.Request, res: express.Response, next: express.NextFunction) => {
const existing = req.headers['mcp-session-id'];
const sessionId = (Array.isArray(existing) ? existing[0] : existing) || crypto.randomUUID();
(req as any).mcpSessionId = sessionId;
const origWriteHead = res.writeHead.bind(res);
res.writeHead = function (statusCode: number, ...rest: any[]) {
res.setHeader('mcp-session-id', sessionId);
return origWriteHead(statusCode, ...rest);
} as typeof res.writeHead;
next();
});
app.use(
pinoHttp({
logger: getLogger(),
customProps: (req) => ({
mcpSessionId: (req as any).mcpSessionId,
}),
customLogLevel: (req, res) => {
if (res.statusCode >= 500) {
return 'error';
Expand Down
2 changes: 1 addition & 1 deletion packages/mcp-server/src/instructions.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import fs from 'fs/promises';
import { readEnv } from './util';
import { getLogger } from './logger';
import { readEnv } from './util';

const INSTRUCTIONS_CACHE_TTL_MS = 15 * 60 * 1000; // 15 minutes

Expand Down
Loading
Loading