Skip to content
Open
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
6 changes: 4 additions & 2 deletions .github/workflows/publish-npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,14 @@ jobs:

- name: Publish to NPM
run: |
if [ -n "${{ github.event.inputs.path }}" ]; then
PATHS_RELEASED='[\"${{ github.event.inputs.path }}\"]'
if [ -n "$INPUT_PATH" ]; then
PATHS_RELEASED="[\"$INPUT_PATH\"]"
else
PATHS_RELEASED='[\".\", \"packages/mcp-server\"]'
fi
pnpm tsn scripts/publish-packages.ts "{ \"paths_released\": \"$PATHS_RELEASED\" }"
env:
INPUT_PATH: ${{ github.event.inputs.path }}

- name: Upload MCP Server DXT GitHub release asset
run: |
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ dist-deno
.eslintcache
dist-bundle
*.mcpb
oidc
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "1.10.3"
".": "1.10.4"
}
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 21
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cas-parser%2Fcas-parser-d9763d006969b49a1473851069fdfa429eb13133b64103a62963bb70ddb22305.yml
openapi_spec_hash: 6aee689b7a759b12c85c088c15e29bc0
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cas-parser%2Fcas-parser-d868ff00b7b07f6b6802b00f22fad531a91a76bb219a634f3f90fe488bd499ba.yml
openapi_spec_hash: 20e9f2fc31feee78878cdf56e46dab60
config_hash: 5509bb7a961ae2e79114b24c381606d4
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# Changelog

## 1.10.4 (2026-04-01)

Full Changelog: [v1.10.3...v1.10.4](https://github.com/CASParser/cas-parser-node/compare/v1.10.3...v1.10.4)

### Bug Fixes

* **internal:** gitignore generated `oidc` dir ([b1df6bc](https://github.com/CASParser/cas-parser-node/commit/b1df6bc1d207373ba90e1087250c4efc615b8ade))


### Chores

* **ci:** escape input path in publish-npm workflow ([f795a47](https://github.com/CASParser/cas-parser-node/commit/f795a4790d772af4853ac232b9f23e1b325ea54c))
* **internal:** improve local docs search for MCP servers ([d83f66b](https://github.com/CASParser/cas-parser-node/commit/d83f66b9f8757aeb8023add6f1bba21e6e284475))
* **internal:** improve local docs search for MCP servers ([8def340](https://github.com/CASParser/cas-parser-node/commit/8def34059bbf2620e2e85b115948e47e4fe6cfca))
* **internal:** support local docs search in MCP servers ([e90f399](https://github.com/CASParser/cas-parser-node/commit/e90f399089d7e5cadd0892126834455ca6617ed4))
* **mcp-server:** add support for session id, forward client info ([9908707](https://github.com/CASParser/cas-parser-node/commit/9908707d2c43b2ad1bf4ead7613ea952319587ff))

## 1.10.3 (2026-03-27)

Full Changelog: [v1.10.2...v1.10.3](https://github.com/CASParser/cas-parser-node/compare/v1.10.2...v1.10.3)
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": "cas-parser-node",
"version": "1.10.3",
"version": "1.10.4",
"description": "The official TypeScript library for the Cas Parser API",
"author": "Cas Parser <sameer@casparser.in>",
"types": "dist/index.d.ts",
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": "cas-parser-node-mcp",
"version": "1.10.3",
"version": "1.10.4",
"description": "The official MCP Server for the Cas Parser API",
"author": {
"name": "Cas Parser",
Expand Down
3 changes: 2 additions & 1 deletion packages/mcp-server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cas-parser-node-mcp",
"version": "1.10.3",
"version": "1.10.4",
"description": "The official MCP Server for the Cas Parser API",
"author": "Cas Parser <sameer@casparser.in>",
"types": "dist/index.d.ts",
Expand Down Expand Up @@ -40,6 +40,7 @@
"cors": "^2.8.5",
"express": "^5.1.0",
"fuse.js": "^7.1.0",
"minisearch": "^7.2.0",
"jq-web": "https://github.com/stainless-api/jq-web/releases/download/v0.8.8/jq-web.tar.gz",
"pino": "^10.3.1",
"pino-http": "^11.0.0",
Expand Down
54 changes: 46 additions & 8 deletions packages/mcp-server/src/docs-search-tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { Tool } from '@modelcontextprotocol/sdk/types.js';
import { Metadata, McpRequestContext, asTextContentResult } from './types';
import { getLogger } from './logger';
import type { LocalDocsSearch } from './local-docs-search';

export const metadata: Metadata = {
resource: 'all',
Expand Down Expand Up @@ -43,20 +44,41 @@ export const tool: Tool = {
const docsSearchURL =
process.env['DOCS_SEARCH_URL'] || 'https://api.stainless.com/api/projects/cas-parser/docs/search';

export const handler = async ({
reqContext,
args,
}: {
reqContext: McpRequestContext;
args: Record<string, unknown> | undefined;
}) => {
let _localSearch: LocalDocsSearch | undefined;

export function setLocalSearch(search: LocalDocsSearch): void {
_localSearch = search;
}

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) ?? 'default';

return _localSearch.search({
query,
language,
detail,
maxResults: 5,
}).results;
}

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: {
...(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 Down Expand Up @@ -94,7 +116,23 @@ export const handler = async ({
},
'Got docs search result',
);
return asTextContentResult(resultBody);
return resultBody;
}

export const handler = async ({
reqContext,
args,
}: {
reqContext: McpRequestContext;
args: Record<string, unknown> | undefined;
}) => {
const body = args ?? {};

if (_localSearch) {
return asTextContentResult(await searchLocal(body));
}

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

export default { metadata, tool, handler };
16 changes: 16 additions & 0 deletions packages/mcp-server/src/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ const newServer = async ({
},
stainlessApiKey: stainlessApiKey,
upstreamClientEnvs,
mcpSessionId: (req as any).mcpSessionId,
mcpClientInfo:
typeof req.body?.params?.clientInfo?.name === 'string' ?
{ name: req.body.params.clientInfo.name, version: String(req.body.params.clientInfo.version ?? '') }
: undefined,
});

return server;
Expand Down Expand Up @@ -135,6 +140,17 @@ 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(),
Expand Down
Loading
Loading