@lightsparkdev/grid-mcp 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +107 -0
- package/code-tool-types.d.mts +14 -0
- package/code-tool-types.d.mts.map +1 -0
- package/code-tool-types.d.ts +14 -0
- package/code-tool-types.d.ts.map +1 -0
- package/code-tool-types.js +4 -0
- package/code-tool-types.js.map +1 -0
- package/code-tool-types.mjs +3 -0
- package/code-tool-types.mjs.map +1 -0
- package/code-tool.d.mts +15 -0
- package/code-tool.d.mts.map +1 -0
- package/code-tool.d.ts +15 -0
- package/code-tool.d.ts.map +1 -0
- package/code-tool.js +116 -0
- package/code-tool.js.map +1 -0
- package/code-tool.mjs +113 -0
- package/code-tool.mjs.map +1 -0
- package/docs-search-tool.d.mts +51 -0
- package/docs-search-tool.d.mts.map +1 -0
- package/docs-search-tool.d.ts +51 -0
- package/docs-search-tool.d.ts.map +1 -0
- package/docs-search-tool.js +51 -0
- package/docs-search-tool.js.map +1 -0
- package/docs-search-tool.mjs +47 -0
- package/docs-search-tool.mjs.map +1 -0
- package/headers.d.mts +4 -0
- package/headers.d.mts.map +1 -0
- package/headers.d.ts +4 -0
- package/headers.d.ts.map +1 -0
- package/headers.js +35 -0
- package/headers.js.map +1 -0
- package/headers.mjs +31 -0
- package/headers.mjs.map +1 -0
- package/http.d.mts +14 -0
- package/http.d.mts.map +1 -0
- package/http.d.ts +14 -0
- package/http.d.ts.map +1 -0
- package/http.js +105 -0
- package/http.js.map +1 -0
- package/http.mjs +97 -0
- package/http.mjs.map +1 -0
- package/index.d.mts +3 -0
- package/index.d.mts.map +1 -0
- package/index.d.ts +3 -0
- package/index.d.ts.map +1 -0
- package/index.js +59 -0
- package/index.js.map +1 -0
- package/index.mjs +57 -0
- package/index.mjs.map +1 -0
- package/methods.d.mts +10 -0
- package/methods.d.mts.map +1 -0
- package/methods.d.ts +10 -0
- package/methods.d.ts.map +1 -0
- package/methods.js +328 -0
- package/methods.js.map +1 -0
- package/methods.mjs +324 -0
- package/methods.mjs.map +1 -0
- package/options.d.mts +15 -0
- package/options.d.mts.map +1 -0
- package/options.d.ts +15 -0
- package/options.d.ts.map +1 -0
- package/options.js +91 -0
- package/options.js.map +1 -0
- package/options.mjs +84 -0
- package/options.mjs.map +1 -0
- package/package.json +174 -0
- package/server.d.mts +30 -0
- package/server.d.mts.map +1 -0
- package/server.d.ts +30 -0
- package/server.d.ts.map +1 -0
- package/server.js +160 -0
- package/server.js.map +1 -0
- package/server.mjs +147 -0
- package/server.mjs.map +1 -0
- package/src/code-tool-types.ts +16 -0
- package/src/code-tool.ts +140 -0
- package/src/docs-search-tool.ts +59 -0
- package/src/headers.ts +39 -0
- package/src/http.ts +130 -0
- package/src/index.ts +65 -0
- package/src/methods.ts +348 -0
- package/src/options.ts +118 -0
- package/src/server.ts +195 -0
- package/src/stdio.ts +13 -0
- package/src/tsconfig.json +11 -0
- package/src/types.ts +115 -0
- package/stdio.d.mts +3 -0
- package/stdio.d.mts.map +1 -0
- package/stdio.d.ts +3 -0
- package/stdio.d.ts.map +1 -0
- package/stdio.js +14 -0
- package/stdio.js.map +1 -0
- package/stdio.mjs +10 -0
- package/stdio.mjs.map +1 -0
- package/types.d.mts +52 -0
- package/types.d.mts.map +1 -0
- package/types.d.ts +52 -0
- package/types.d.ts.map +1 -0
- package/types.js +58 -0
- package/types.js.map +1 -0
- package/types.mjs +53 -0
- package/types.mjs.map +1 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Metadata } from "./types.mjs";
|
|
2
|
+
import { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
3
|
+
export declare const metadata: Metadata;
|
|
4
|
+
export declare const tool: Tool;
|
|
5
|
+
export declare const handler: (_: unknown, args: Record<string, unknown> | undefined) => Promise<import("./types").ToolCallResult>;
|
|
6
|
+
declare const _default: {
|
|
7
|
+
metadata: Metadata;
|
|
8
|
+
tool: {
|
|
9
|
+
inputSchema: {
|
|
10
|
+
[x: string]: unknown;
|
|
11
|
+
type: "object";
|
|
12
|
+
properties?: {
|
|
13
|
+
[x: string]: object;
|
|
14
|
+
} | undefined;
|
|
15
|
+
required?: string[] | undefined;
|
|
16
|
+
};
|
|
17
|
+
name: string;
|
|
18
|
+
description?: string | undefined;
|
|
19
|
+
outputSchema?: {
|
|
20
|
+
[x: string]: unknown;
|
|
21
|
+
type: "object";
|
|
22
|
+
properties?: {
|
|
23
|
+
[x: string]: object;
|
|
24
|
+
} | undefined;
|
|
25
|
+
required?: string[] | undefined;
|
|
26
|
+
} | undefined;
|
|
27
|
+
annotations?: {
|
|
28
|
+
title?: string | undefined;
|
|
29
|
+
readOnlyHint?: boolean | undefined;
|
|
30
|
+
destructiveHint?: boolean | undefined;
|
|
31
|
+
idempotentHint?: boolean | undefined;
|
|
32
|
+
openWorldHint?: boolean | undefined;
|
|
33
|
+
} | undefined;
|
|
34
|
+
execution?: {
|
|
35
|
+
taskSupport?: "optional" | "required" | "forbidden" | undefined;
|
|
36
|
+
} | undefined;
|
|
37
|
+
_meta?: {
|
|
38
|
+
[x: string]: unknown;
|
|
39
|
+
} | undefined;
|
|
40
|
+
icons?: {
|
|
41
|
+
src: string;
|
|
42
|
+
mimeType?: string | undefined;
|
|
43
|
+
sizes?: string[] | undefined;
|
|
44
|
+
theme?: "light" | "dark" | undefined;
|
|
45
|
+
}[] | undefined;
|
|
46
|
+
title?: string | undefined;
|
|
47
|
+
};
|
|
48
|
+
handler: (_: unknown, args: Record<string, unknown> | undefined) => Promise<import("./types").ToolCallResult>;
|
|
49
|
+
};
|
|
50
|
+
export default _default;
|
|
51
|
+
//# sourceMappingURL=docs-search-tool.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docs-search-tool.d.mts","sourceRoot":"","sources":["src/docs-search-tool.ts"],"names":[],"mappings":"OAEO,EAAE,QAAQ,EAAuB;OAEjC,EAAE,IAAI,EAAE,MAAM,oCAAoC;AAEzD,eAAO,MAAM,QAAQ,EAAE,QAKtB,CAAC;AAEF,eAAO,MAAM,IAAI,EAAE,IA0BlB,CAAC;AAKF,eAAO,MAAM,OAAO,GAAU,GAAG,OAAO,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,8CAYlF,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAZ+B,OAAO,QAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS;;AAcnF,wBAA2C"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Metadata } from "./types.js";
|
|
2
|
+
import { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
3
|
+
export declare const metadata: Metadata;
|
|
4
|
+
export declare const tool: Tool;
|
|
5
|
+
export declare const handler: (_: unknown, args: Record<string, unknown> | undefined) => Promise<import("./types").ToolCallResult>;
|
|
6
|
+
declare const _default: {
|
|
7
|
+
metadata: Metadata;
|
|
8
|
+
tool: {
|
|
9
|
+
inputSchema: {
|
|
10
|
+
[x: string]: unknown;
|
|
11
|
+
type: "object";
|
|
12
|
+
properties?: {
|
|
13
|
+
[x: string]: object;
|
|
14
|
+
} | undefined;
|
|
15
|
+
required?: string[] | undefined;
|
|
16
|
+
};
|
|
17
|
+
name: string;
|
|
18
|
+
description?: string | undefined;
|
|
19
|
+
outputSchema?: {
|
|
20
|
+
[x: string]: unknown;
|
|
21
|
+
type: "object";
|
|
22
|
+
properties?: {
|
|
23
|
+
[x: string]: object;
|
|
24
|
+
} | undefined;
|
|
25
|
+
required?: string[] | undefined;
|
|
26
|
+
} | undefined;
|
|
27
|
+
annotations?: {
|
|
28
|
+
title?: string | undefined;
|
|
29
|
+
readOnlyHint?: boolean | undefined;
|
|
30
|
+
destructiveHint?: boolean | undefined;
|
|
31
|
+
idempotentHint?: boolean | undefined;
|
|
32
|
+
openWorldHint?: boolean | undefined;
|
|
33
|
+
} | undefined;
|
|
34
|
+
execution?: {
|
|
35
|
+
taskSupport?: "optional" | "required" | "forbidden" | undefined;
|
|
36
|
+
} | undefined;
|
|
37
|
+
_meta?: {
|
|
38
|
+
[x: string]: unknown;
|
|
39
|
+
} | undefined;
|
|
40
|
+
icons?: {
|
|
41
|
+
src: string;
|
|
42
|
+
mimeType?: string | undefined;
|
|
43
|
+
sizes?: string[] | undefined;
|
|
44
|
+
theme?: "light" | "dark" | undefined;
|
|
45
|
+
}[] | undefined;
|
|
46
|
+
title?: string | undefined;
|
|
47
|
+
};
|
|
48
|
+
handler: (_: unknown, args: Record<string, unknown> | undefined) => Promise<import("./types").ToolCallResult>;
|
|
49
|
+
};
|
|
50
|
+
export default _default;
|
|
51
|
+
//# sourceMappingURL=docs-search-tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docs-search-tool.d.ts","sourceRoot":"","sources":["src/docs-search-tool.ts"],"names":[],"mappings":"OAEO,EAAE,QAAQ,EAAuB;OAEjC,EAAE,IAAI,EAAE,MAAM,oCAAoC;AAEzD,eAAO,MAAM,QAAQ,EAAE,QAKtB,CAAC;AAEF,eAAO,MAAM,IAAI,EAAE,IA0BlB,CAAC;AAKF,eAAO,MAAM,OAAO,GAAU,GAAG,OAAO,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,8CAYlF,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAZ+B,OAAO,QAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS;;AAcnF,wBAA2C"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.handler = exports.tool = exports.metadata = void 0;
|
|
5
|
+
const types_1 = require("./types.js");
|
|
6
|
+
exports.metadata = {
|
|
7
|
+
resource: 'all',
|
|
8
|
+
operation: 'read',
|
|
9
|
+
tags: [],
|
|
10
|
+
httpMethod: 'get',
|
|
11
|
+
};
|
|
12
|
+
exports.tool = {
|
|
13
|
+
name: 'search_docs',
|
|
14
|
+
description: 'Search for documentation for how to use the client to interact with the API.',
|
|
15
|
+
inputSchema: {
|
|
16
|
+
type: 'object',
|
|
17
|
+
properties: {
|
|
18
|
+
query: {
|
|
19
|
+
type: 'string',
|
|
20
|
+
description: 'The query to search for.',
|
|
21
|
+
},
|
|
22
|
+
language: {
|
|
23
|
+
type: 'string',
|
|
24
|
+
description: 'The language for the SDK to search for.',
|
|
25
|
+
enum: ['http', 'python', 'go', 'typescript', 'javascript', 'terraform', 'ruby', 'java', 'kotlin'],
|
|
26
|
+
},
|
|
27
|
+
detail: {
|
|
28
|
+
type: 'string',
|
|
29
|
+
description: 'The amount of detail to return.',
|
|
30
|
+
enum: ['default', 'verbose'],
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
required: ['query', 'language'],
|
|
34
|
+
},
|
|
35
|
+
annotations: {
|
|
36
|
+
readOnlyHint: true,
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
const docsSearchURL = process.env['DOCS_SEARCH_URL'] || 'https://api.stainless.com/api/projects/grid/docs/search';
|
|
40
|
+
const handler = async (_, args) => {
|
|
41
|
+
const body = args;
|
|
42
|
+
const query = new URLSearchParams(body).toString();
|
|
43
|
+
const result = await fetch(`${docsSearchURL}?${query}`);
|
|
44
|
+
if (!result.ok) {
|
|
45
|
+
throw new Error(`${result.status}: ${result.statusText} when using doc search tool. Details: ${await result.text()}`);
|
|
46
|
+
}
|
|
47
|
+
return (0, types_1.asTextContentResult)(await result.json());
|
|
48
|
+
};
|
|
49
|
+
exports.handler = handler;
|
|
50
|
+
exports.default = { metadata: exports.metadata, tool: exports.tool, handler: exports.handler };
|
|
51
|
+
//# sourceMappingURL=docs-search-tool.js.map
|
|
@@ -0,0 +1 @@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Aa,IAAI,KAAK,EAAE,CAAC,CAAC;IAExD,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CACb,GAAG,MAAM,CAAC,MAAM,KAAK,MAAM,CAAC,UAAU,yCAAyC,MAAM,MAAM,CAAC,IAAI,EAAE,EAAE,CACrG,CAAC;IACJ,CAAC;IAED,OAAO,IAAA,2BAAmB,EAAC,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;AAClD,CAAC,CAAC;AAZW,QAAA,OAAO,WAYlB;AAEF,kBAAe,EAAE,QAAQ,EAAR,gBAAQ,EAAE,IAAI,EAAJ,YAAI,EAAE,OAAO,EAAP,eAAO,EAAE,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
import { asTextContentResult } from "./types.mjs";
|
|
3
|
+
export const metadata = {
|
|
4
|
+
resource: 'all',
|
|
5
|
+
operation: 'read',
|
|
6
|
+
tags: [],
|
|
7
|
+
httpMethod: 'get',
|
|
8
|
+
};
|
|
9
|
+
export const tool = {
|
|
10
|
+
name: 'search_docs',
|
|
11
|
+
description: 'Search for documentation for how to use the client to interact with the API.',
|
|
12
|
+
inputSchema: {
|
|
13
|
+
type: 'object',
|
|
14
|
+
properties: {
|
|
15
|
+
query: {
|
|
16
|
+
type: 'string',
|
|
17
|
+
description: 'The query to search for.',
|
|
18
|
+
},
|
|
19
|
+
language: {
|
|
20
|
+
type: 'string',
|
|
21
|
+
description: 'The language for the SDK to search for.',
|
|
22
|
+
enum: ['http', 'python', 'go', 'typescript', 'javascript', 'terraform', 'ruby', 'java', 'kotlin'],
|
|
23
|
+
},
|
|
24
|
+
detail: {
|
|
25
|
+
type: 'string',
|
|
26
|
+
description: 'The amount of detail to return.',
|
|
27
|
+
enum: ['default', 'verbose'],
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
required: ['query', 'language'],
|
|
31
|
+
},
|
|
32
|
+
annotations: {
|
|
33
|
+
readOnlyHint: true,
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
const docsSearchURL = process.env['DOCS_SEARCH_URL'] || 'https://api.stainless.com/api/projects/grid/docs/search';
|
|
37
|
+
export const handler = async (_, args) => {
|
|
38
|
+
const body = args;
|
|
39
|
+
const query = new URLSearchParams(body).toString();
|
|
40
|
+
const result = await fetch(`${docsSearchURL}?${query}`);
|
|
41
|
+
if (!result.ok) {
|
|
42
|
+
throw new Error(`${result.status}: ${result.statusText} when using doc search tool. Details: ${await result.text()}`);
|
|
43
|
+
}
|
|
44
|
+
return asTextContentResult(await result.json());
|
|
45
|
+
};
|
|
46
|
+
export default { metadata, tool, handler };
|
|
47
|
+
//# sourceMappingURL=docs-search-tool.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docs-search-tool.mjs","sourceRoot":"","sources":["src/docs-search-tool.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAY,mBAAmB,EAAE;AAIxC,MAAM,CAAC,MAAM,QAAQ,GAAa;IAChC,QAAQ,EAAE,KAAK;IACf,SAAS,EAAE,MAAM;IACjB,IAAI,EAAE,EAAE;IACR,UAAU,EAAE,KAAK;CAClB,CAAC;AAEF,MAAM,CAAC,MAAM,IAAI,GAAS;IACxB,IAAI,EAAE,aAAa;IACnB,WAAW,EAAE,8EAA8E;IAC3F,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,0BAA0B;aACxC;YACD,QAAQ,EAAE;gBACR,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,yCAAyC;gBACtD,IAAI,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC;aAClG;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CAAC"}
|
package/headers.d.ts
ADDED
package/headers.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"headers.d.ts","sourceRoot":"","sources":["src/headers.ts"],"names":[],"mappings":"OAEO,EAAE,eAAe,EAAE,MAAM,WAAW;OACpC,EAAE,aAAa,EAAE,MAAM,qBAAqB;AAEnD,eAAO,MAAM,gBAAgB,GAAI,KAAK,eAAe,EAAE,WAAW,OAAO,KAAG,OAAO,CAAC,aAAa,CAiChG,CAAC"}
|
package/headers.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.parseAuthHeaders = void 0;
|
|
5
|
+
const parseAuthHeaders = (req, required) => {
|
|
6
|
+
if (req.headers.authorization) {
|
|
7
|
+
const scheme = req.headers.authorization.split(' ')[0];
|
|
8
|
+
const value = req.headers.authorization.slice(scheme.length + 1);
|
|
9
|
+
switch (scheme) {
|
|
10
|
+
case 'Basic':
|
|
11
|
+
const rawValue = Buffer.from(value, 'base64').toString();
|
|
12
|
+
return {
|
|
13
|
+
username: rawValue.slice(0, rawValue.search(':')),
|
|
14
|
+
password: rawValue.slice(rawValue.search(':') + 1),
|
|
15
|
+
};
|
|
16
|
+
default:
|
|
17
|
+
throw new Error('Unsupported authorization scheme. Expected the "Authorization" header to be a supported scheme (Basic).');
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
else if (required) {
|
|
21
|
+
throw new Error('Missing required Authorization header; see WWW-Authenticate header for details.');
|
|
22
|
+
}
|
|
23
|
+
const username = Array.isArray(req.headers['x-grid-client-id']) ?
|
|
24
|
+
req.headers['x-grid-client-id'][0]
|
|
25
|
+
: req.headers['x-grid-client-id'];
|
|
26
|
+
const password = Array.isArray(req.headers['x-grid-client-secret']) ?
|
|
27
|
+
req.headers['x-grid-client-secret'][0]
|
|
28
|
+
: req.headers['x-grid-client-secret'];
|
|
29
|
+
const webhookSignature = Array.isArray(req.headers['x-grid-signature']) ?
|
|
30
|
+
req.headers['x-grid-signature'][0]
|
|
31
|
+
: req.headers['x-grid-signature'];
|
|
32
|
+
return { username, password, webhookSignature };
|
|
33
|
+
};
|
|
34
|
+
exports.parseAuthHeaders = parseAuthHeaders;
|
|
35
|
+
//# sourceMappingURL=headers.js.map
|
package/headers.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"headers.js","sourceRoot":"","sources":["src/headers.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAK/E,MAAM,gBAAgB,GAAG,CAAC,GAAoB,EAAE,QAAkB,EAA0B,EAAE;IACnG,IAAI,GAAG,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC;QAC9B,MAAM,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAE,CAAC;QACxD,MAAM,KAAK,GAAG,GAAG,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACjE,QAAQ,MAAM,EAAE,CAAC;YACf,KAAK,OAAO;gBACV,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,QAAQ,EAAE,CAAC;gBACzD,OAAO;oBACL,QAAQ,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;oBACjD,QAAQ,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;iBACnD,CAAC;YACJ;gBACE,MAAM,IAAI,KAAK,CACb,yGAAyG,CAC1G,CAAC;QACN,CAAC;IACH,CAAC;SAAM,IAAI,QAAQ,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,iFAAiF,CAAC,CAAC;IACrG,CAAC;IAED,MAAM,QAAQ,GACZ,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC;QAC9C,GAAG,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC;QACpC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACpC,MAAM,QAAQ,GACZ,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC;QAClD,GAAG,CAAC,OAAO,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC;QACxC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,sBAAsB,CAAC,CAAC;IACxC,MAAM,gBAAgB,GACpB,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC;QAC9C,GAAG,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC;QACpC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACpC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,gBAAgB,EAAE,CAAC;AAClD,CAAC,CAAC;AAjCW,QAAA,gBAAgB,oBAiC3B"}
|
package/headers.mjs
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
export const parseAuthHeaders = (req, required) => {
|
|
3
|
+
if (req.headers.authorization) {
|
|
4
|
+
const scheme = req.headers.authorization.split(' ')[0];
|
|
5
|
+
const value = req.headers.authorization.slice(scheme.length + 1);
|
|
6
|
+
switch (scheme) {
|
|
7
|
+
case 'Basic':
|
|
8
|
+
const rawValue = Buffer.from(value, 'base64').toString();
|
|
9
|
+
return {
|
|
10
|
+
username: rawValue.slice(0, rawValue.search(':')),
|
|
11
|
+
password: rawValue.slice(rawValue.search(':') + 1),
|
|
12
|
+
};
|
|
13
|
+
default:
|
|
14
|
+
throw new Error('Unsupported authorization scheme. Expected the "Authorization" header to be a supported scheme (Basic).');
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
else if (required) {
|
|
18
|
+
throw new Error('Missing required Authorization header; see WWW-Authenticate header for details.');
|
|
19
|
+
}
|
|
20
|
+
const username = Array.isArray(req.headers['x-grid-client-id']) ?
|
|
21
|
+
req.headers['x-grid-client-id'][0]
|
|
22
|
+
: req.headers['x-grid-client-id'];
|
|
23
|
+
const password = Array.isArray(req.headers['x-grid-client-secret']) ?
|
|
24
|
+
req.headers['x-grid-client-secret'][0]
|
|
25
|
+
: req.headers['x-grid-client-secret'];
|
|
26
|
+
const webhookSignature = Array.isArray(req.headers['x-grid-signature']) ?
|
|
27
|
+
req.headers['x-grid-signature'][0]
|
|
28
|
+
: req.headers['x-grid-signature'];
|
|
29
|
+
return { username, password, webhookSignature };
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=headers.mjs.map
|
package/headers.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"headers.mjs","sourceRoot":"","sources":["src/headers.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAKtF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,GAAoB,EAAE,QAAkB,EAA0B,EAAE;IACnG,IAAI,GAAG,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC;QAC9B,MAAM,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAE,CAAC;QACxD,MAAM,KAAK,GAAG,GAAG,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACjE,QAAQ,MAAM,EAAE,CAAC;YACf,KAAK,OA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AQ,EAAE,gBAAgB,EAAE,CAAC;AAClD,CAAC,CAAC"}
|
package/http.d.mts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import express from 'express';
|
|
2
|
+
import { McpOptions } from "./options.mjs";
|
|
3
|
+
import { ClientOptions } from "./server.mjs";
|
|
4
|
+
export declare const streamableHTTPApp: ({ clientOptions, mcpOptions, debug, }: {
|
|
5
|
+
clientOptions?: ClientOptions;
|
|
6
|
+
mcpOptions: McpOptions;
|
|
7
|
+
debug: boolean;
|
|
8
|
+
}) => express.Express;
|
|
9
|
+
export declare const launchStreamableHTTPServer: (params: {
|
|
10
|
+
mcpOptions: McpOptions;
|
|
11
|
+
debug: boolean;
|
|
12
|
+
port: number | string | undefined;
|
|
13
|
+
}) => Promise<void>;
|
|
14
|
+
//# sourceMappingURL=http.d.mts.map
|
package/http.d.mts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.mts","sourceRoot":"","sources":["src/http.ts"],"names":[],"mappings":"OAIO,OAAO,MAAM,SAAS;OAGtB,EAAE,UAAU,EAAE;OACd,EAAE,aAAa,EAA+B;AAuErD,eAAO,MAAM,iBAAiB,GAAI,uCAI/B;IACD,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,UAAU,EAAE,UAAU,CAAC;IACvB,KAAK,EAAE,OAAO,CAAC;CAChB,KAAG,OAAO,CAAC,OAwBX,CAAC;AAEF,eAAO,MAAM,0BAA0B,GAAU,QAAQ;IACvD,UAAU,EAAE,UAAU,CAAC;IACvB,KAAK,EAAE,OAAO,CAAC;IACf,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;CACnC,kBAYA,CAAC"}
|
package/http.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import express from 'express';
|
|
2
|
+
import { McpOptions } from "./options.js";
|
|
3
|
+
import { ClientOptions } from "./server.js";
|
|
4
|
+
export declare const streamableHTTPApp: ({ clientOptions, mcpOptions, debug, }: {
|
|
5
|
+
clientOptions?: ClientOptions;
|
|
6
|
+
mcpOptions: McpOptions;
|
|
7
|
+
debug: boolean;
|
|
8
|
+
}) => express.Express;
|
|
9
|
+
export declare const launchStreamableHTTPServer: (params: {
|
|
10
|
+
mcpOptions: McpOptions;
|
|
11
|
+
debug: boolean;
|
|
12
|
+
port: number | string | undefined;
|
|
13
|
+
}) => Promise<void>;
|
|
14
|
+
//# sourceMappingURL=http.d.ts.map
|
package/http.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["src/http.ts"],"names":[],"mappings":"OAIO,OAAO,MAAM,SAAS;OAGtB,EAAE,UAAU,EAAE;OACd,EAAE,aAAa,EAA+B;AAuErD,eAAO,MAAM,iBAAiB,GAAI,uCAI/B;IACD,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,UAAU,EAAE,UAAU,CAAC;IACvB,KAAK,EAAE,OAAO,CAAC;CAChB,KAAG,OAAO,CAAC,OAwBX,CAAC;AAEF,eAAO,MAAM,0BAA0B,GAAU,QAAQ;IACvD,UAAU,EAAE,UAAU,CAAC;IACvB,KAAK,EAAE,OAAO,CAAC;IACf,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;CACnC,kBAYA,CAAC"}
|
package/http.js
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.launchStreamableHTTPServer = exports.streamableHTTPApp = void 0;
|
|
8
|
+
const streamableHttp_js_1 = require("@modelcontextprotocol/sdk/server/streamableHttp.js");
|
|
9
|
+
const express_1 = __importDefault(require("express"));
|
|
10
|
+
const morgan_1 = __importDefault(require("morgan"));
|
|
11
|
+
const morgan_body_1 = __importDefault(require("morgan-body"));
|
|
12
|
+
const server_1 = require("./server.js");
|
|
13
|
+
const headers_1 = require("./headers.js");
|
|
14
|
+
const newServer = async ({ clientOptions, mcpOptions, req, res, }) => {
|
|
15
|
+
const server = await (0, server_1.newMcpServer)();
|
|
16
|
+
try {
|
|
17
|
+
const authOptions = (0, headers_1.parseAuthHeaders)(req, false);
|
|
18
|
+
await (0, server_1.initMcpServer)({
|
|
19
|
+
server: server,
|
|
20
|
+
mcpOptions: mcpOptions,
|
|
21
|
+
clientOptions: {
|
|
22
|
+
...clientOptions,
|
|
23
|
+
...authOptions,
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
res.status(401).json({
|
|
29
|
+
jsonrpc: '2.0',
|
|
30
|
+
error: {
|
|
31
|
+
code: -32000,
|
|
32
|
+
message: `Unauthorized: ${error instanceof Error ? error.message : error}`,
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
return server;
|
|
38
|
+
};
|
|
39
|
+
const post = (options) => async (req, res) => {
|
|
40
|
+
const server = await newServer({ ...options, req, res });
|
|
41
|
+
// If we return null, we already set the authorization error.
|
|
42
|
+
if (server === null)
|
|
43
|
+
return;
|
|
44
|
+
const transport = new streamableHttp_js_1.StreamableHTTPServerTransport();
|
|
45
|
+
await server.connect(transport);
|
|
46
|
+
await transport.handleRequest(req, res, req.body);
|
|
47
|
+
};
|
|
48
|
+
const get = async (req, res) => {
|
|
49
|
+
res.status(405).json({
|
|
50
|
+
jsonrpc: '2.0',
|
|
51
|
+
error: {
|
|
52
|
+
code: -32000,
|
|
53
|
+
message: 'Method not supported',
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
const del = async (req, res) => {
|
|
58
|
+
res.status(405).json({
|
|
59
|
+
jsonrpc: '2.0',
|
|
60
|
+
error: {
|
|
61
|
+
code: -32000,
|
|
62
|
+
message: 'Method not supported',
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
const streamableHTTPApp = ({ clientOptions = {}, mcpOptions, debug, }) => {
|
|
67
|
+
const app = (0, express_1.default)();
|
|
68
|
+
app.set('query parser', 'extended');
|
|
69
|
+
app.use(express_1.default.json());
|
|
70
|
+
if (debug) {
|
|
71
|
+
(0, morgan_body_1.default)(app, {
|
|
72
|
+
logAllReqHeader: true,
|
|
73
|
+
logAllResHeader: true,
|
|
74
|
+
logRequestBody: true,
|
|
75
|
+
logResponseBody: true,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
app.use((0, morgan_1.default)('combined'));
|
|
80
|
+
}
|
|
81
|
+
app.get('/health', async (req, res) => {
|
|
82
|
+
res.status(200).send('OK');
|
|
83
|
+
});
|
|
84
|
+
app.get('/', get);
|
|
85
|
+
app.post('/', post({ clientOptions, mcpOptions }));
|
|
86
|
+
app.delete('/', del);
|
|
87
|
+
return app;
|
|
88
|
+
};
|
|
89
|
+
exports.streamableHTTPApp = streamableHTTPApp;
|
|
90
|
+
const launchStreamableHTTPServer = async (params) => {
|
|
91
|
+
const app = (0, exports.streamableHTTPApp)({ mcpOptions: params.mcpOptions, debug: params.debug });
|
|
92
|
+
const server = app.listen(params.port);
|
|
93
|
+
const address = server.address();
|
|
94
|
+
if (typeof address === 'string') {
|
|
95
|
+
console.error(`MCP Server running on streamable HTTP at ${address}`);
|
|
96
|
+
}
|
|
97
|
+
else if (address !== null) {
|
|
98
|
+
console.error(`MCP Server running on streamable HTTP on port ${address.port}`);
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
console.error(`MCP Server running on streamable HTTP on port ${params.port}`);
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
exports.launchStreamableHTTPServer = launchStreamableHTTPServer;
|
|
105
|
+
//# sourceMapping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AAM,CAAC,IAAI,EAAE,CAAC,CAAC;IAChF,CAAC;AACH,CAAC,CAAC;AAhBW,QAAA,0BAA0B,8BAgBrC"}
|
package/http.mjs
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
|
3
|
+
import express from 'express';
|
|
4
|
+
import morgan from 'morgan';
|
|
5
|
+
import morganBody from 'morgan-body';
|
|
6
|
+
import { initMcpServer, newMcpServer } from "./server.mjs";
|
|
7
|
+
import { parseAuthHeaders } from "./headers.mjs";
|
|
8
|
+
const newServer = async ({ clientOptions, mcpOptions, req, res, }) => {
|
|
9
|
+
const server = await newMcpServer();
|
|
10
|
+
try {
|
|
11
|
+
const authOptions = parseAuthHeaders(req, false);
|
|
12
|
+
await initMcpServer({
|
|
13
|
+
server: server,
|
|
14
|
+
mcpOptions: mcpOptions,
|
|
15
|
+
clientOptions: {
|
|
16
|
+
...clientOptions,
|
|
17
|
+
...authOptions,
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
res.status(401).json({
|
|
23
|
+
jsonrpc: '2.0',
|
|
24
|
+
error: {
|
|
25
|
+
code: -32000,
|
|
26
|
+
message: `Unauthorized: ${error instanceof Error ? error.message : error}`,
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
return server;
|
|
32
|
+
};
|
|
33
|
+
const post = (options) => async (req, res) => {
|
|
34
|
+
const server = await newServer({ ...options, req, res });
|
|
35
|
+
// If we return null, we already set the authorization error.
|
|
36
|
+
if (server === null)
|
|
37
|
+
return;
|
|
38
|
+
const transport = new StreamableHTTPServerTransport();
|
|
39
|
+
await server.connect(transport);
|
|
40
|
+
await transport.handleRequest(req, res, req.body);
|
|
41
|
+
};
|
|
42
|
+
const get = async (req, res) => {
|
|
43
|
+
res.status(405).json({
|
|
44
|
+
jsonrpc: '2.0',
|
|
45
|
+
error: {
|
|
46
|
+
code: -32000,
|
|
47
|
+
message: 'Method not supported',
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
const del = async (req, res) => {
|
|
52
|
+
res.status(405).json({
|
|
53
|
+
jsonrpc: '2.0',
|
|
54
|
+
error: {
|
|
55
|
+
code: -32000,
|
|
56
|
+
message: 'Method not supported',
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
export const streamableHTTPApp = ({ clientOptions = {}, mcpOptions, debug, }) => {
|
|
61
|
+
const app = express();
|
|
62
|
+
app.set('query parser', 'extended');
|
|
63
|
+
app.use(express.json());
|
|
64
|
+
if (debug) {
|
|
65
|
+
morganBody(app, {
|
|
66
|
+
logAllReqHeader: true,
|
|
67
|
+
logAllResHeader: true,
|
|
68
|
+
logRequestBody: true,
|
|
69
|
+
logResponseBody: true,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
app.use(morgan('combined'));
|
|
74
|
+
}
|
|
75
|
+
app.get('/health', async (req, res) => {
|
|
76
|
+
res.status(200).send('OK');
|
|
77
|
+
});
|
|
78
|
+
app.get('/', get);
|
|
79
|
+
app.post('/', post({ clientOptions, mcpOptions }));
|
|
80
|
+
app.delete('/', del);
|
|
81
|
+
return app;
|
|
82
|
+
};
|
|
83
|
+
export const launchStreamableHTTPServer = async (params) => {
|
|
84
|
+
const app = streamableHTTPApp({ mcpOptions: params.mcpOptions, debug: params.debug });
|
|
85
|
+
const server = app.listen(params.port);
|
|
86
|
+
const address = server.address();
|
|
87
|
+
if (typeof address === 'string') {
|
|
88
|
+
console.error(`MCP Server running on streamable HTTP at ${address}`);
|
|
89
|
+
}
|
|
90
|
+
else if (address !== null) {
|
|
91
|
+
console.error(`MCP Server running on streamable HTTP on port ${address.port}`);
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
console.error(`MCP Server running on streamable HTTP on port ${params.port}`);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
//# sourceMappingURL=http.mjs.map
|
package/http.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.mjs","sourceRoot":"","sources":["src/http.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAG/E,EAAE,6BAA6B,EAAE,MAAM,oDAAoD;OAC3F,OAAO,MAAM,SAAS;OACtB,MAAM,MAAM,QAAQ;OACpB,UAAU,MAAM,aAAa;OAE7B,EAAiB,aAAa,EAAE,YAAY,EAAE;OAC9C,EAAE,gBAAgB,EAAE;AAE3B,MAAM,SAAS,GAAG,KAAK,EAAE,EACvB,aAAa,EACb,UAAU,EACV,GAAG,EACH,GAAG,GAMJ,EAA6B,EAAE;IAC9B,MAAM,MAAM,GAAG,MAAM,YAAY,EAAE,CAAC;IAEpC,IAAI,CAAC;QACH,MAAM,WAAW,GAAG,gBAAgB,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACjD,MAAM,aAAa,CAAC;YAClB,MAAM,EAAE,MAAM;YACd,UAAU,EAAE,UAAU;YACtB,aAAa,EAAE;gBACb,GAAG,aAAa;gBAChB,GAAG,WAAW;aACf;SACF,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;YACnB,OAAO,EAAE,KAAK;YACd,KAAK,EAAE;gBACL,IAAI,EAAE,CAAC,KAAK;gBACZ,OAAO,EAAE,iBAAiB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,EAAE;aAC3E;SACF,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAEF,MAAM,IAAI,GACR,CAAC,OAAiE,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AAC;QAC5B,OAAO,CAAC,KAAK,CAAC,iDAAiD,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;IACjF,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,KAAK,CAAC,iDAAiD,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;IAChF,CAAC;AACH,CAAC,CAAC"}
|
package/index.d.mts
ADDED
package/index.d.mts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":""}
|
package/index.d.ts
ADDED
package/index.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":""}
|