scorecard-ai-mcp 1.0.0 → 1.2.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/README.md +2 -1
- package/compat.d.mts +2 -0
- package/compat.d.mts.map +1 -1
- package/compat.d.ts +2 -0
- package/compat.d.ts.map +1 -1
- package/compat.js +38 -1
- package/compat.js.map +1 -1
- package/compat.mjs +37 -0
- package/compat.mjs.map +1 -1
- package/index.d.mts +1 -0
- package/index.d.ts +1 -0
- package/index.js.map +1 -1
- package/index.mjs +1 -0
- package/index.mjs.map +1 -1
- package/options.d.mts +9 -6
- package/options.d.mts.map +1 -1
- package/options.d.ts +9 -6
- package/options.d.ts.map +1 -1
- package/options.js +5 -46
- package/options.js.map +1 -1
- package/options.mjs +5 -46
- package/options.mjs.map +1 -1
- package/package.json +4 -4
- package/server.d.mts +16 -2
- package/server.d.mts.map +1 -1
- package/server.d.ts +16 -2
- package/server.d.ts.map +1 -1
- package/server.js +33 -11
- package/server.js.map +1 -1
- package/server.mjs +33 -12
- package/server.mjs.map +1 -1
- package/src/compat.ts +40 -0
- package/src/index.ts +4 -2
- package/src/options.ts +12 -54
- package/src/server.ts +45 -16
- package/src/tools/index.ts +5 -2
- package/src/tools/metrics/create-metrics.ts +2 -1
- package/src/tools/metrics/update-metrics.ts +252 -0
- package/src/tools/types.ts +0 -1
- package/tools/index.d.mts.map +1 -1
- package/tools/index.d.ts.map +1 -1
- package/tools/index.js +5 -2
- package/tools/index.js.map +1 -1
- package/tools/index.mjs +5 -2
- package/tools/index.mjs.map +1 -1
- package/tools/metrics/create-metrics.d.mts +13 -0
- package/tools/metrics/create-metrics.d.mts.map +1 -1
- package/tools/metrics/create-metrics.d.ts +13 -0
- package/tools/metrics/create-metrics.d.ts.map +1 -1
- package/tools/metrics/create-metrics.js +1 -1
- package/tools/metrics/create-metrics.js.map +1 -1
- package/tools/metrics/create-metrics.mjs +1 -1
- package/tools/metrics/create-metrics.mjs.map +1 -1
- package/tools/metrics/update-metrics.d.mts +45 -0
- package/tools/metrics/update-metrics.d.mts.map +1 -0
- package/tools/metrics/update-metrics.d.ts +45 -0
- package/tools/metrics/update-metrics.d.ts.map +1 -0
- package/tools/metrics/update-metrics.js +245 -0
- package/tools/metrics/update-metrics.js.map +1 -0
- package/tools/metrics/update-metrics.mjs +241 -0
- package/tools/metrics/update-metrics.mjs.map +1 -0
- package/tools/projects/create-projects.d.mts +13 -0
- package/tools/projects/create-projects.d.mts.map +1 -1
- package/tools/projects/create-projects.d.ts +13 -0
- package/tools/projects/create-projects.d.ts.map +1 -1
- package/tools/projects/list-projects.d.mts +13 -0
- package/tools/projects/list-projects.d.mts.map +1 -1
- package/tools/projects/list-projects.d.ts +13 -0
- package/tools/projects/list-projects.d.ts.map +1 -1
- package/tools/records/create-records.d.mts +13 -0
- package/tools/records/create-records.d.mts.map +1 -1
- package/tools/records/create-records.d.ts +13 -0
- package/tools/records/create-records.d.ts.map +1 -1
- package/tools/runs/create-runs.d.mts +13 -0
- package/tools/runs/create-runs.d.mts.map +1 -1
- package/tools/runs/create-runs.d.ts +13 -0
- package/tools/runs/create-runs.d.ts.map +1 -1
- package/tools/scores/upsert-scores.d.mts +13 -0
- package/tools/scores/upsert-scores.d.mts.map +1 -1
- package/tools/scores/upsert-scores.d.ts +13 -0
- package/tools/scores/upsert-scores.d.ts.map +1 -1
- package/tools/systems/create-systems.d.mts +13 -0
- package/tools/systems/create-systems.d.mts.map +1 -1
- package/tools/systems/create-systems.d.ts +13 -0
- package/tools/systems/create-systems.d.ts.map +1 -1
- package/tools/systems/delete-systems.d.mts +13 -0
- package/tools/systems/delete-systems.d.mts.map +1 -1
- package/tools/systems/delete-systems.d.ts +13 -0
- package/tools/systems/delete-systems.d.ts.map +1 -1
- package/tools/systems/get-systems.d.mts +13 -0
- package/tools/systems/get-systems.d.mts.map +1 -1
- package/tools/systems/get-systems.d.ts +13 -0
- package/tools/systems/get-systems.d.ts.map +1 -1
- package/tools/systems/list-systems.d.mts +13 -0
- package/tools/systems/list-systems.d.mts.map +1 -1
- package/tools/systems/list-systems.d.ts +13 -0
- package/tools/systems/list-systems.d.ts.map +1 -1
- package/tools/systems/update-systems.d.mts +13 -0
- package/tools/systems/update-systems.d.mts.map +1 -1
- package/tools/systems/update-systems.d.ts +13 -0
- package/tools/systems/update-systems.d.ts.map +1 -1
- package/tools/systems/versions/create-systems-versions.d.mts +13 -0
- package/tools/systems/versions/create-systems-versions.d.mts.map +1 -1
- package/tools/systems/versions/create-systems-versions.d.ts +13 -0
- package/tools/systems/versions/create-systems-versions.d.ts.map +1 -1
- package/tools/systems/versions/get-systems-versions.d.mts +13 -0
- package/tools/systems/versions/get-systems-versions.d.mts.map +1 -1
- package/tools/systems/versions/get-systems-versions.d.ts +13 -0
- package/tools/systems/versions/get-systems-versions.d.ts.map +1 -1
- package/tools/systems/versions/list-systems-versions.d.mts +13 -0
- package/tools/systems/versions/list-systems-versions.d.mts.map +1 -1
- package/tools/systems/versions/list-systems-versions.d.ts +13 -0
- package/tools/systems/versions/list-systems-versions.d.ts.map +1 -1
- package/tools/testcases/create-testcases.d.mts +13 -0
- package/tools/testcases/create-testcases.d.mts.map +1 -1
- package/tools/testcases/create-testcases.d.ts +13 -0
- package/tools/testcases/create-testcases.d.ts.map +1 -1
- package/tools/testcases/delete-testcases.d.mts +13 -0
- package/tools/testcases/delete-testcases.d.mts.map +1 -1
- package/tools/testcases/delete-testcases.d.ts +13 -0
- package/tools/testcases/delete-testcases.d.ts.map +1 -1
- package/tools/testcases/get-testcases.d.mts +13 -0
- package/tools/testcases/get-testcases.d.mts.map +1 -1
- package/tools/testcases/get-testcases.d.ts +13 -0
- package/tools/testcases/get-testcases.d.ts.map +1 -1
- package/tools/testcases/list-testcases.d.mts +13 -0
- package/tools/testcases/list-testcases.d.mts.map +1 -1
- package/tools/testcases/list-testcases.d.ts +13 -0
- package/tools/testcases/list-testcases.d.ts.map +1 -1
- package/tools/testcases/update-testcases.d.mts +13 -0
- package/tools/testcases/update-testcases.d.mts.map +1 -1
- package/tools/testcases/update-testcases.d.ts +13 -0
- package/tools/testcases/update-testcases.d.ts.map +1 -1
- package/tools/testsets/create-testsets.d.mts +13 -0
- package/tools/testsets/create-testsets.d.mts.map +1 -1
- package/tools/testsets/create-testsets.d.ts +13 -0
- package/tools/testsets/create-testsets.d.ts.map +1 -1
- package/tools/testsets/delete-testsets.d.mts +13 -0
- package/tools/testsets/delete-testsets.d.mts.map +1 -1
- package/tools/testsets/delete-testsets.d.ts +13 -0
- package/tools/testsets/delete-testsets.d.ts.map +1 -1
- package/tools/testsets/get-testsets.d.mts +13 -0
- package/tools/testsets/get-testsets.d.mts.map +1 -1
- package/tools/testsets/get-testsets.d.ts +13 -0
- package/tools/testsets/get-testsets.d.ts.map +1 -1
- package/tools/testsets/list-testsets.d.mts +13 -0
- package/tools/testsets/list-testsets.d.mts.map +1 -1
- package/tools/testsets/list-testsets.d.ts +13 -0
- package/tools/testsets/list-testsets.d.ts.map +1 -1
- package/tools/testsets/update-testsets.d.mts +13 -0
- package/tools/testsets/update-testsets.d.mts.map +1 -1
- package/tools/testsets/update-testsets.d.ts +13 -0
- package/tools/testsets/update-testsets.d.ts.map +1 -1
- package/tools/types.d.mts.map +1 -1
- package/tools/types.d.ts.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "scorecard-ai-mcp",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "The official MCP Server for the Scorecard API",
|
|
5
5
|
"author": "Scorecard <team@scorecard.io>",
|
|
6
6
|
"types": "./index.d.ts",
|
|
@@ -24,11 +24,11 @@
|
|
|
24
24
|
"fix": "eslint --fix --ext ts,js ."
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"scorecard-ai": "^1.
|
|
28
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
27
|
+
"scorecard-ai": "^1.2.0",
|
|
28
|
+
"@modelcontextprotocol/sdk": "^1.11.5",
|
|
29
29
|
"yargs": "^17.7.2",
|
|
30
30
|
"@cloudflare/cabidela": "^0.2.4",
|
|
31
|
-
"zod": "^3.
|
|
31
|
+
"zod": "^3.25.20",
|
|
32
32
|
"zod-to-json-schema": "^3.24.5"
|
|
33
33
|
},
|
|
34
34
|
"bin": {
|
package/server.d.mts
CHANGED
|
@@ -2,15 +2,29 @@ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
|
2
2
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
3
|
import { Endpoint, HandlerFunction } from "./tools.mjs";
|
|
4
4
|
import { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
5
|
+
import { ClientOptions } from 'scorecard-ai';
|
|
5
6
|
import Scorecard from 'scorecard-ai';
|
|
6
7
|
import { ClientCapabilities } from "./compat.mjs";
|
|
7
|
-
import {
|
|
8
|
+
import { McpOptions } from "./options.mjs";
|
|
9
|
+
export { McpOptions } from "./options.mjs";
|
|
10
|
+
export { ClientType } from "./compat.mjs";
|
|
11
|
+
export { Filter } from "./tools.mjs";
|
|
12
|
+
export { ClientOptions } from 'scorecard-ai';
|
|
8
13
|
export { endpoints } from "./tools.mjs";
|
|
9
14
|
export declare const server: McpServer;
|
|
10
15
|
/**
|
|
11
16
|
* Initializes the provided MCP Server with the given tools and handlers.
|
|
12
17
|
* If not provided, the default client, tools and handlers will be used.
|
|
13
18
|
*/
|
|
19
|
+
export declare function initMcpServer(params: {
|
|
20
|
+
server: Server | McpServer;
|
|
21
|
+
clientOptions: ClientOptions;
|
|
22
|
+
mcpOptions: McpOptions;
|
|
23
|
+
endpoints?: {
|
|
24
|
+
tool: Tool;
|
|
25
|
+
handler: HandlerFunction;
|
|
26
|
+
}[];
|
|
27
|
+
}): void;
|
|
14
28
|
export declare function init(params: {
|
|
15
29
|
server: Server | McpServer;
|
|
16
30
|
client?: Scorecard;
|
|
@@ -23,7 +37,7 @@ export declare function init(params: {
|
|
|
23
37
|
/**
|
|
24
38
|
* Selects the tools to include in the MCP Server based on the provided options.
|
|
25
39
|
*/
|
|
26
|
-
export declare function selectTools(endpoints: Endpoint[], options:
|
|
40
|
+
export declare function selectTools(endpoints: Endpoint[], options: McpOptions): Endpoint[];
|
|
27
41
|
/**
|
|
28
42
|
* Runs the provided handler with the given client and arguments.
|
|
29
43
|
*/
|
package/server.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.mts","sourceRoot":"","sources":["src/server.ts"],"names":[],"mappings":"OAEO,EAAE,MAAM,EAAE,MAAM,2CAA2C;OAC3D,EAAE,SAAS,EAAE,MAAM,yCAAyC;OAC5D,EAAE,QAAQ,EAAa,eAAe,EAAS;OAC/C,EAAiD,IAAI,EAAE,MAAM,oCAAoC;OACjG,SAAS,MAAM,cAAc;OAC7B,EAEL,kBAAkB,
|
|
1
|
+
{"version":3,"file":"server.d.mts","sourceRoot":"","sources":["src/server.ts"],"names":[],"mappings":"OAEO,EAAE,MAAM,EAAE,MAAM,2CAA2C;OAC3D,EAAE,SAAS,EAAE,MAAM,yCAAyC;OAC5D,EAAE,QAAQ,EAAa,eAAe,EAAS;OAC/C,EAAiD,IAAI,EAAE,MAAM,oCAAoC;OACjG,EAAE,aAAa,EAAE,MAAM,cAAc;OACrC,SAAS,MAAM,cAAc;OAC7B,EAEL,kBAAkB,EAInB;OAEM,EAAE,UAAU,EAAE;OAEd,EAAE,UAAU,EAAE;OACd,EAAE,UAAU,EAAE;OACd,EAAE,MAAM,EAAE;OACV,EAAE,aAAa,EAAE,MAAM,cAAc;OACrC,EAAE,SAAS,EAAE;AAGpB,eAAO,MAAM,MAAM,WAUlB,CAAC;AAEF;;;GAGG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE;IACpC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,aAAa,EAAE,aAAa,CAAC;IAC7B,UAAU,EAAE,UAAU,CAAC;IACvB,SAAS,CAAC,EAAE;QAAE,IAAI,EAAE,IAAI,CAAC;QAAC,OAAO,EAAE,eAAe,CAAA;KAAE,EAAE,CAAC;CACxD,QAQA;AAED,wBAAgB,IAAI,CAAC,MAAM,EAAE;IAC3B,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,SAAS,CAAC,EAAE;QAAE,IAAI,EAAE,IAAI,CAAC;QAAC,OAAO,EAAE,eAAe,CAAA;KAAE,EAAE,CAAC;IACvD,YAAY,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAC;CAC5C,QA4BA;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,SAAS,EAAE,QAAQ,EAAE,EAAE,OAAO,EAAE,UAAU,cAqBrE;AAED;;GAEG;AACH,wBAAsB,cAAc,CAClC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,eAAe,EACxB,MAAM,EAAE,SAAS,EACjB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EACzC,oBAAoB,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,mDAOnD;AAED,eAAO,MAAM,OAAO,GAAI,KAAK,MAAM,KAAG,MAAM,GAAG,SAO9C,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,KAAK,MAAM,KAAG,MAM5C,CAAC"}
|
package/server.d.ts
CHANGED
|
@@ -2,15 +2,29 @@ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
|
2
2
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
3
|
import { Endpoint, HandlerFunction } from "./tools.js";
|
|
4
4
|
import { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
5
|
+
import { ClientOptions } from 'scorecard-ai';
|
|
5
6
|
import Scorecard from 'scorecard-ai';
|
|
6
7
|
import { ClientCapabilities } from "./compat.js";
|
|
7
|
-
import {
|
|
8
|
+
import { McpOptions } from "./options.js";
|
|
9
|
+
export { McpOptions } from "./options.js";
|
|
10
|
+
export { ClientType } from "./compat.js";
|
|
11
|
+
export { Filter } from "./tools.js";
|
|
12
|
+
export { ClientOptions } from 'scorecard-ai';
|
|
8
13
|
export { endpoints } from "./tools.js";
|
|
9
14
|
export declare const server: McpServer;
|
|
10
15
|
/**
|
|
11
16
|
* Initializes the provided MCP Server with the given tools and handlers.
|
|
12
17
|
* If not provided, the default client, tools and handlers will be used.
|
|
13
18
|
*/
|
|
19
|
+
export declare function initMcpServer(params: {
|
|
20
|
+
server: Server | McpServer;
|
|
21
|
+
clientOptions: ClientOptions;
|
|
22
|
+
mcpOptions: McpOptions;
|
|
23
|
+
endpoints?: {
|
|
24
|
+
tool: Tool;
|
|
25
|
+
handler: HandlerFunction;
|
|
26
|
+
}[];
|
|
27
|
+
}): void;
|
|
14
28
|
export declare function init(params: {
|
|
15
29
|
server: Server | McpServer;
|
|
16
30
|
client?: Scorecard;
|
|
@@ -23,7 +37,7 @@ export declare function init(params: {
|
|
|
23
37
|
/**
|
|
24
38
|
* Selects the tools to include in the MCP Server based on the provided options.
|
|
25
39
|
*/
|
|
26
|
-
export declare function selectTools(endpoints: Endpoint[], options:
|
|
40
|
+
export declare function selectTools(endpoints: Endpoint[], options: McpOptions): Endpoint[];
|
|
27
41
|
/**
|
|
28
42
|
* Runs the provided handler with the given client and arguments.
|
|
29
43
|
*/
|
package/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["src/server.ts"],"names":[],"mappings":"OAEO,EAAE,MAAM,EAAE,MAAM,2CAA2C;OAC3D,EAAE,SAAS,EAAE,MAAM,yCAAyC;OAC5D,EAAE,QAAQ,EAAa,eAAe,EAAS;OAC/C,EAAiD,IAAI,EAAE,MAAM,oCAAoC;OACjG,SAAS,MAAM,cAAc;OAC7B,EAEL,kBAAkB,
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"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AAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EACzC,oBAAoB,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,mDAOnD;AAED,eAAO,MAAM,OAAO,GAAI,KAAK,MAAM,KAAG,MAAM,GAAG,SAO9C,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,KAAK,MAAM,KAAG,MAM5C,CAAC"}
|
package/server.js
CHANGED
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
};
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.readEnvOrError = exports.readEnv = exports.server = exports.endpoints = void 0;
|
|
8
|
+
exports.initMcpServer = initMcpServer;
|
|
8
9
|
exports.init = init;
|
|
9
10
|
exports.selectTools = selectTools;
|
|
10
11
|
exports.executeHandler = executeHandler;
|
|
@@ -19,7 +20,7 @@ Object.defineProperty(exports, "endpoints", { enumerable: true, get: function ()
|
|
|
19
20
|
// Create server instance
|
|
20
21
|
exports.server = new mcp_js_1.McpServer({
|
|
21
22
|
name: 'scorecard_ai_api',
|
|
22
|
-
version: '1.
|
|
23
|
+
version: '1.2.0',
|
|
23
24
|
}, {
|
|
24
25
|
capabilities: {
|
|
25
26
|
tools: {},
|
|
@@ -29,11 +30,24 @@ exports.server = new mcp_js_1.McpServer({
|
|
|
29
30
|
* Initializes the provided MCP Server with the given tools and handlers.
|
|
30
31
|
* If not provided, the default client, tools and handlers will be used.
|
|
31
32
|
*/
|
|
33
|
+
function initMcpServer(params) {
|
|
34
|
+
const transformedEndpoints = selectTools(tools_1.endpoints, params.mcpOptions);
|
|
35
|
+
const client = new scorecard_ai_1.default(params.clientOptions);
|
|
36
|
+
const capabilities = {
|
|
37
|
+
...compat_1.defaultClientCapabilities,
|
|
38
|
+
...(params.mcpOptions.client ? compat_1.knownClients[params.mcpOptions.client] : params.mcpOptions.capabilities),
|
|
39
|
+
};
|
|
40
|
+
init({ server: params.server, client, endpoints: transformedEndpoints, capabilities });
|
|
41
|
+
}
|
|
32
42
|
function init(params) {
|
|
33
43
|
const server = params.server instanceof mcp_js_1.McpServer ? params.server.server : params.server;
|
|
34
44
|
const providedEndpoints = params.endpoints || tools_1.endpoints;
|
|
35
45
|
const endpointMap = Object.fromEntries(providedEndpoints.map((endpoint) => [endpoint.tool.name, endpoint]));
|
|
36
|
-
const client = params.client ||
|
|
46
|
+
const client = params.client ||
|
|
47
|
+
new scorecard_ai_1.default({
|
|
48
|
+
environment: ((0, exports.readEnv)('SCORECARD_ENVIRONMENT') || undefined),
|
|
49
|
+
defaultHeaders: { 'X-Stainless-MCP': 'true' },
|
|
50
|
+
});
|
|
37
51
|
server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => {
|
|
38
52
|
return {
|
|
39
53
|
tools: providedEndpoints.map((endpoint) => endpoint.tool),
|
|
@@ -53,17 +67,25 @@ function init(params) {
|
|
|
53
67
|
*/
|
|
54
68
|
function selectTools(endpoints, options) {
|
|
55
69
|
const filteredEndpoints = (0, tools_1.query)(options.filters, endpoints);
|
|
56
|
-
|
|
57
|
-
if (
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
includedTools.push(...(0, dynamic_tools_1.dynamicTools)(endpoints));
|
|
70
|
+
let includedTools = filteredEndpoints;
|
|
71
|
+
if (includedTools.length > 0) {
|
|
72
|
+
if (options.includeDynamicTools) {
|
|
73
|
+
includedTools = (0, dynamic_tools_1.dynamicTools)(includedTools);
|
|
74
|
+
}
|
|
62
75
|
}
|
|
63
|
-
|
|
64
|
-
|
|
76
|
+
else {
|
|
77
|
+
if (options.includeAllTools) {
|
|
78
|
+
includedTools = endpoints;
|
|
79
|
+
}
|
|
80
|
+
else if (options.includeDynamicTools) {
|
|
81
|
+
includedTools = (0, dynamic_tools_1.dynamicTools)(endpoints);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
includedTools = endpoints;
|
|
85
|
+
}
|
|
65
86
|
}
|
|
66
|
-
|
|
87
|
+
const capabilities = { ...compat_1.defaultClientCapabilities, ...options.capabilities };
|
|
88
|
+
return (0, compat_1.applyCompatibilityTransformations)(includedTools, capabilities);
|
|
67
89
|
}
|
|
68
90
|
/**
|
|
69
91
|
* Runs the provided handler with the given client and arguments.
|
package/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["src/server.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;;;;
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["src/server.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;;;;AAyCtF,sCAaC;AAED,oBAiCC;AAKD,kCAqBC;AAKD,wCAYC;AAjID,oEAAoE;AACpE,sCAAsE;AACtE,iEAAyG;AAEzG,gEAAqC;AACrC,wCAMkB;AAClB,sDAA+C;AAO/C,oCAAoC;AAA3B,kGAAA,SAAS,OAAA;AAElB,yBAAyB;AACZ,QAAA,MAAM,GAAG,IAAI,kBAAS,CACjC;IACE,IAAI,EAAE,kBAAkB;IACxB,OAAO,EAAE,OAAO;CACjB,EACD;IACE,YAAY,EAAE;QACZ,KAAK,EAAE,EAAE;KACV;CACF,CACF,CAAC;AAEF;;;GAGG;AACH,SAAgB,aAAa,CAAC,MAK7B;IACC,MAAM,oBAAoB,GAAG,WAAW,CAAC,iBAAS,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC;IACvE,MAAM,MAAM,GAAG,IAAI,sBAAS,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;IACnD,MAAM,YAAY,GAAG;QACnB,GAAG,kCAAyB;QAC5B,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,qBAAY,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,YAAY,CAAC;KACxG,CAAC;IACF,IAAI,CAAC,EAAE,MAAM,EAA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E,CAAC;QAC9B,IAAI,GAAG,IAAA,0BAAiB,EAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IACnD,CAAC;IACD,OAAO,MAAM,OAAO,CAAC,MAAM,EAAE,IAAI,IAAI,EAAE,CAAC,CAAC;AAC3C,CAAC;AAEM,MAAM,OAAO,GAAG,CAAC,GAAW,EAAsB,EAAE;IACzD,IAAI,OAAQ,UAAkB,CAAC,OAAO,KAAK,WAAW,EAAE,CAAC;QACvD,OAAQ,UAAkB,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,CAAC;IACxD,CAAC;SAAM,IAAI,OAAQ,UAAkB,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;QAC3D,OAAQ,UAAkB,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,CAAC;IAC1D,CAAC;IACD,OAAO;AACT,CAAC,CAAC;AAPW,QAAA,OAAO,WAOlB;AAEK,MAAM,cAAc,GAAG,CAAC,GAAW,EAAU,EAAE;IACpD,IAAI,QAAQ,GAAG,IAAA,eAAO,EAAC,GAAG,CAAC,CAAC;IAC5B,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,wBAAwB,GAAG,aAAa,CAAC,CAAC;IAC5D,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AANW,QAAA,cAAc,kBAMzB"}
|
package/server.mjs
CHANGED
|
@@ -3,13 +3,13 @@ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
|
3
3
|
import { endpoints, query } from "./tools.mjs";
|
|
4
4
|
import { CallToolRequestSchema, ListToolsRequestSchema } from '@modelcontextprotocol/sdk/types.js';
|
|
5
5
|
import Scorecard from 'scorecard-ai';
|
|
6
|
-
import { applyCompatibilityTransformations, defaultClientCapabilities, parseEmbeddedJSON, } from "./compat.mjs";
|
|
6
|
+
import { applyCompatibilityTransformations, defaultClientCapabilities, knownClients, parseEmbeddedJSON, } from "./compat.mjs";
|
|
7
7
|
import { dynamicTools } from "./dynamic-tools.mjs";
|
|
8
8
|
export { endpoints } from "./tools.mjs";
|
|
9
9
|
// Create server instance
|
|
10
10
|
export const server = new McpServer({
|
|
11
11
|
name: 'scorecard_ai_api',
|
|
12
|
-
version: '1.
|
|
12
|
+
version: '1.2.0',
|
|
13
13
|
}, {
|
|
14
14
|
capabilities: {
|
|
15
15
|
tools: {},
|
|
@@ -19,11 +19,24 @@ export const server = new McpServer({
|
|
|
19
19
|
* Initializes the provided MCP Server with the given tools and handlers.
|
|
20
20
|
* If not provided, the default client, tools and handlers will be used.
|
|
21
21
|
*/
|
|
22
|
+
export function initMcpServer(params) {
|
|
23
|
+
const transformedEndpoints = selectTools(endpoints, params.mcpOptions);
|
|
24
|
+
const client = new Scorecard(params.clientOptions);
|
|
25
|
+
const capabilities = {
|
|
26
|
+
...defaultClientCapabilities,
|
|
27
|
+
...(params.mcpOptions.client ? knownClients[params.mcpOptions.client] : params.mcpOptions.capabilities),
|
|
28
|
+
};
|
|
29
|
+
init({ server: params.server, client, endpoints: transformedEndpoints, capabilities });
|
|
30
|
+
}
|
|
22
31
|
export function init(params) {
|
|
23
32
|
const server = params.server instanceof McpServer ? params.server.server : params.server;
|
|
24
33
|
const providedEndpoints = params.endpoints || endpoints;
|
|
25
34
|
const endpointMap = Object.fromEntries(providedEndpoints.map((endpoint) => [endpoint.tool.name, endpoint]));
|
|
26
|
-
const client = params.client ||
|
|
35
|
+
const client = params.client ||
|
|
36
|
+
new Scorecard({
|
|
37
|
+
environment: (readEnv('SCORECARD_ENVIRONMENT') || undefined),
|
|
38
|
+
defaultHeaders: { 'X-Stainless-MCP': 'true' },
|
|
39
|
+
});
|
|
27
40
|
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
28
41
|
return {
|
|
29
42
|
tools: providedEndpoints.map((endpoint) => endpoint.tool),
|
|
@@ -43,17 +56,25 @@ export function init(params) {
|
|
|
43
56
|
*/
|
|
44
57
|
export function selectTools(endpoints, options) {
|
|
45
58
|
const filteredEndpoints = query(options.filters, endpoints);
|
|
46
|
-
|
|
47
|
-
if (
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
includedTools.push(...dynamicTools(endpoints));
|
|
59
|
+
let includedTools = filteredEndpoints;
|
|
60
|
+
if (includedTools.length > 0) {
|
|
61
|
+
if (options.includeDynamicTools) {
|
|
62
|
+
includedTools = dynamicTools(includedTools);
|
|
63
|
+
}
|
|
52
64
|
}
|
|
53
|
-
|
|
54
|
-
|
|
65
|
+
else {
|
|
66
|
+
if (options.includeAllTools) {
|
|
67
|
+
includedTools = endpoints;
|
|
68
|
+
}
|
|
69
|
+
else if (options.includeDynamicTools) {
|
|
70
|
+
includedTools = dynamicTools(endpoints);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
includedTools = endpoints;
|
|
74
|
+
}
|
|
55
75
|
}
|
|
56
|
-
|
|
76
|
+
const capabilities = { ...defaultClientCapabilities, ...options.capabilities };
|
|
77
|
+
return applyCompatibilityTransformations(includedTools, capabilities);
|
|
57
78
|
}
|
|
58
79
|
/**
|
|
59
80
|
* Runs the provided handler with the given client and arguments.
|
package/server.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.mjs","sourceRoot":"","sources":["src/server.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAG/E,EAAE,SAAS,EAAE,MAAM,yCAAyC;OAC5D,EAAY,SAAS,EAAmB,KAAK,EAAE;OAC/C,EAAE,qBAAqB,EAAE,sBAAsB,EAAQ,MAAM,oCAAoC;
|
|
1
|
+
{"version":3,"file":"server.mjs","sourceRoot":"","sources":["src/server.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAG/E,EAAE,SAAS,EAAE,MAAM,yCAAyC;OAC5D,EAAY,SAAS,EAAmB,KAAK,EAAE;OAC/C,EA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AC;SAAM,IAAI,OAAQ,UAAkB,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;QAC3D,OAAQ,UAAkB,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,CAAC;IAC1D,CAAC;IACD,OAAO;AACT,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,GAAW,EAAU,EAAE;IACpD,IAAI,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IAC5B,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,wBAAwB,GAAG,aAAa,CAAC,CAAC;IAC5D,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC"}
|
package/src/compat.ts
CHANGED
|
@@ -19,6 +19,46 @@ export const defaultClientCapabilities: ClientCapabilities = {
|
|
|
19
19
|
toolNameLength: undefined,
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
+
export type ClientType = 'openai-agents' | 'claude' | 'claude-code' | 'cursor';
|
|
23
|
+
|
|
24
|
+
// Client presets for compatibility
|
|
25
|
+
// Note that these could change over time as models get better, so this is
|
|
26
|
+
// a best effort.
|
|
27
|
+
export const knownClients: Record<ClientType, ClientCapabilities> = {
|
|
28
|
+
'openai-agents': {
|
|
29
|
+
topLevelUnions: false,
|
|
30
|
+
validJson: true,
|
|
31
|
+
refs: true,
|
|
32
|
+
unions: true,
|
|
33
|
+
formats: true,
|
|
34
|
+
toolNameLength: undefined,
|
|
35
|
+
},
|
|
36
|
+
claude: {
|
|
37
|
+
topLevelUnions: true,
|
|
38
|
+
validJson: false,
|
|
39
|
+
refs: true,
|
|
40
|
+
unions: true,
|
|
41
|
+
formats: true,
|
|
42
|
+
toolNameLength: undefined,
|
|
43
|
+
},
|
|
44
|
+
'claude-code': {
|
|
45
|
+
topLevelUnions: false,
|
|
46
|
+
validJson: true,
|
|
47
|
+
refs: true,
|
|
48
|
+
unions: true,
|
|
49
|
+
formats: true,
|
|
50
|
+
toolNameLength: undefined,
|
|
51
|
+
},
|
|
52
|
+
cursor: {
|
|
53
|
+
topLevelUnions: false,
|
|
54
|
+
validJson: true,
|
|
55
|
+
refs: false,
|
|
56
|
+
unions: false,
|
|
57
|
+
formats: false,
|
|
58
|
+
toolNameLength: 50,
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
|
|
22
62
|
/**
|
|
23
63
|
* Attempts to parse strings into JSON objects
|
|
24
64
|
*/
|
package/src/index.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
1
3
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
2
4
|
import { init, selectTools, server } from './server';
|
|
3
5
|
import { Endpoint, endpoints } from './tools';
|
|
4
|
-
import {
|
|
6
|
+
import { McpOptions, parseOptions } from './options';
|
|
5
7
|
|
|
6
8
|
async function main() {
|
|
7
9
|
const options = parseOptionsOrError();
|
|
@@ -41,7 +43,7 @@ function parseOptionsOrError() {
|
|
|
41
43
|
}
|
|
42
44
|
}
|
|
43
45
|
|
|
44
|
-
function selectToolsOrError(endpoints: Endpoint[], options:
|
|
46
|
+
function selectToolsOrError(endpoints: Endpoint[], options: McpOptions) {
|
|
45
47
|
try {
|
|
46
48
|
const includedTools = selectTools(endpoints, options);
|
|
47
49
|
if (includedTools.length === 0) {
|
package/src/options.ts
CHANGED
|
@@ -1,55 +1,19 @@
|
|
|
1
1
|
import yargs from 'yargs';
|
|
2
2
|
import { hideBin } from 'yargs/helpers';
|
|
3
3
|
import { endpoints, Filter } from './tools';
|
|
4
|
-
import { ClientCapabilities } from './compat';
|
|
4
|
+
import { ClientCapabilities, knownClients, ClientType } from './compat';
|
|
5
5
|
|
|
6
|
-
type
|
|
7
|
-
|
|
8
|
-
// Client presets for compatibility
|
|
9
|
-
// Note that these could change over time as models get better, so this is
|
|
10
|
-
// a best effort.
|
|
11
|
-
const CLIENT_PRESETS: Record<ClientType, ClientCapabilities> = {
|
|
12
|
-
'openai-agents': {
|
|
13
|
-
topLevelUnions: false,
|
|
14
|
-
validJson: true,
|
|
15
|
-
refs: true,
|
|
16
|
-
unions: true,
|
|
17
|
-
formats: true,
|
|
18
|
-
toolNameLength: undefined,
|
|
19
|
-
},
|
|
20
|
-
claude: {
|
|
21
|
-
topLevelUnions: true,
|
|
22
|
-
validJson: false,
|
|
23
|
-
refs: true,
|
|
24
|
-
unions: true,
|
|
25
|
-
formats: true,
|
|
26
|
-
toolNameLength: undefined,
|
|
27
|
-
},
|
|
28
|
-
'claude-code': {
|
|
29
|
-
topLevelUnions: false,
|
|
30
|
-
validJson: true,
|
|
31
|
-
refs: true,
|
|
32
|
-
unions: true,
|
|
33
|
-
formats: true,
|
|
34
|
-
toolNameLength: undefined,
|
|
35
|
-
},
|
|
36
|
-
cursor: {
|
|
37
|
-
topLevelUnions: false,
|
|
38
|
-
validJson: true,
|
|
39
|
-
refs: false,
|
|
40
|
-
unions: false,
|
|
41
|
-
formats: false,
|
|
42
|
-
toolNameLength: 50,
|
|
43
|
-
},
|
|
6
|
+
export type CLIOptions = McpOptions & {
|
|
7
|
+
list: boolean;
|
|
44
8
|
};
|
|
45
9
|
|
|
46
|
-
export
|
|
10
|
+
export type McpOptions = {
|
|
11
|
+
client: ClientType | undefined;
|
|
47
12
|
includeDynamicTools: boolean | undefined;
|
|
48
13
|
includeAllTools: boolean | undefined;
|
|
49
14
|
filters: Filter[];
|
|
50
|
-
capabilities
|
|
51
|
-
|
|
52
|
-
}
|
|
15
|
+
capabilities?: Partial<ClientCapabilities>;
|
|
16
|
+
};
|
|
53
17
|
|
|
54
18
|
const CAPABILITY_CHOICES = [
|
|
55
19
|
'top-level-unions',
|
|
@@ -80,7 +44,7 @@ function parseCapabilityValue(cap: string): { name: Capability; value?: number }
|
|
|
80
44
|
return { name: cap as Capability };
|
|
81
45
|
}
|
|
82
46
|
|
|
83
|
-
export function parseOptions():
|
|
47
|
+
export function parseOptions(): CLIOptions {
|
|
84
48
|
const opts = yargs(hideBin(process.argv))
|
|
85
49
|
.option('tools', {
|
|
86
50
|
type: 'string',
|
|
@@ -141,7 +105,7 @@ export function parseOptions(): ParsedOptions {
|
|
|
141
105
|
})
|
|
142
106
|
.option('client', {
|
|
143
107
|
type: 'string',
|
|
144
|
-
choices: Object.keys(
|
|
108
|
+
choices: Object.keys(knownClients),
|
|
145
109
|
description: 'Specify the MCP client being used',
|
|
146
110
|
})
|
|
147
111
|
.option('capability', {
|
|
@@ -229,14 +193,6 @@ export function parseOptions(): ParsedOptions {
|
|
|
229
193
|
toolNameLength: undefined,
|
|
230
194
|
};
|
|
231
195
|
|
|
232
|
-
// Apply client preset if specified
|
|
233
|
-
if (typeof argv.client === 'string') {
|
|
234
|
-
const clientKey = argv.client as ClientType;
|
|
235
|
-
if (CLIENT_PRESETS[clientKey]) {
|
|
236
|
-
Object.assign(clientCapabilities, CLIENT_PRESETS[clientKey]);
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
|
|
240
196
|
// Apply individual capability overrides
|
|
241
197
|
if (Array.isArray(argv.capability)) {
|
|
242
198
|
for (const cap of argv.capability) {
|
|
@@ -282,7 +238,9 @@ export function parseOptions(): ParsedOptions {
|
|
|
282
238
|
const includeAllTools =
|
|
283
239
|
explicitTools ? argv.tools?.includes('all') && !argv.noTools?.includes('all') : undefined;
|
|
284
240
|
|
|
241
|
+
const client = argv.client as ClientType;
|
|
285
242
|
return {
|
|
243
|
+
client: client && knownClients[client] ? client : undefined,
|
|
286
244
|
includeDynamicTools,
|
|
287
245
|
includeAllTools,
|
|
288
246
|
filters,
|
|
@@ -323,7 +281,7 @@ Client Presets (--client):
|
|
|
323
281
|
Presets like '--client=openai-agents' or '--client=cursor' automatically configure these capabilities based on current known limitations of those clients, simplifying setup.
|
|
324
282
|
|
|
325
283
|
Current presets:
|
|
326
|
-
${JSON.stringify(
|
|
284
|
+
${JSON.stringify(knownClients, null, 2)}
|
|
327
285
|
`;
|
|
328
286
|
}
|
|
329
287
|
|
package/src/server.ts
CHANGED
|
@@ -4,22 +4,29 @@ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
|
4
4
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
5
5
|
import { Endpoint, endpoints, HandlerFunction, query } from './tools';
|
|
6
6
|
import { CallToolRequestSchema, ListToolsRequestSchema, Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
7
|
+
import { ClientOptions } from 'scorecard-ai';
|
|
7
8
|
import Scorecard from 'scorecard-ai';
|
|
8
9
|
import {
|
|
9
10
|
applyCompatibilityTransformations,
|
|
10
11
|
ClientCapabilities,
|
|
11
12
|
defaultClientCapabilities,
|
|
13
|
+
knownClients,
|
|
12
14
|
parseEmbeddedJSON,
|
|
13
15
|
} from './compat';
|
|
14
16
|
import { dynamicTools } from './dynamic-tools';
|
|
15
|
-
import {
|
|
17
|
+
import { McpOptions } from './options';
|
|
18
|
+
|
|
19
|
+
export { McpOptions } from './options';
|
|
20
|
+
export { ClientType } from './compat';
|
|
21
|
+
export { Filter } from './tools';
|
|
22
|
+
export { ClientOptions } from 'scorecard-ai';
|
|
16
23
|
export { endpoints } from './tools';
|
|
17
24
|
|
|
18
25
|
// Create server instance
|
|
19
26
|
export const server = new McpServer(
|
|
20
27
|
{
|
|
21
28
|
name: 'scorecard_ai_api',
|
|
22
|
-
version: '1.
|
|
29
|
+
version: '1.2.0',
|
|
23
30
|
},
|
|
24
31
|
{
|
|
25
32
|
capabilities: {
|
|
@@ -32,6 +39,21 @@ export const server = new McpServer(
|
|
|
32
39
|
* Initializes the provided MCP Server with the given tools and handlers.
|
|
33
40
|
* If not provided, the default client, tools and handlers will be used.
|
|
34
41
|
*/
|
|
42
|
+
export function initMcpServer(params: {
|
|
43
|
+
server: Server | McpServer;
|
|
44
|
+
clientOptions: ClientOptions;
|
|
45
|
+
mcpOptions: McpOptions;
|
|
46
|
+
endpoints?: { tool: Tool; handler: HandlerFunction }[];
|
|
47
|
+
}) {
|
|
48
|
+
const transformedEndpoints = selectTools(endpoints, params.mcpOptions);
|
|
49
|
+
const client = new Scorecard(params.clientOptions);
|
|
50
|
+
const capabilities = {
|
|
51
|
+
...defaultClientCapabilities,
|
|
52
|
+
...(params.mcpOptions.client ? knownClients[params.mcpOptions.client] : params.mcpOptions.capabilities),
|
|
53
|
+
};
|
|
54
|
+
init({ server: params.server, client, endpoints: transformedEndpoints, capabilities });
|
|
55
|
+
}
|
|
56
|
+
|
|
35
57
|
export function init(params: {
|
|
36
58
|
server: Server | McpServer;
|
|
37
59
|
client?: Scorecard;
|
|
@@ -44,7 +66,11 @@ export function init(params: {
|
|
|
44
66
|
const endpointMap = Object.fromEntries(providedEndpoints.map((endpoint) => [endpoint.tool.name, endpoint]));
|
|
45
67
|
|
|
46
68
|
const client =
|
|
47
|
-
params.client ||
|
|
69
|
+
params.client ||
|
|
70
|
+
new Scorecard({
|
|
71
|
+
environment: (readEnv('SCORECARD_ENVIRONMENT') || undefined) as any,
|
|
72
|
+
defaultHeaders: { 'X-Stainless-MCP': 'true' },
|
|
73
|
+
});
|
|
48
74
|
|
|
49
75
|
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
50
76
|
return {
|
|
@@ -66,24 +92,27 @@ export function init(params: {
|
|
|
66
92
|
/**
|
|
67
93
|
* Selects the tools to include in the MCP Server based on the provided options.
|
|
68
94
|
*/
|
|
69
|
-
export function selectTools(endpoints: Endpoint[], options:
|
|
95
|
+
export function selectTools(endpoints: Endpoint[], options: McpOptions) {
|
|
70
96
|
const filteredEndpoints = query(options.filters, endpoints);
|
|
71
97
|
|
|
72
|
-
|
|
98
|
+
let includedTools = filteredEndpoints;
|
|
73
99
|
|
|
74
|
-
if (
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
100
|
+
if (includedTools.length > 0) {
|
|
101
|
+
if (options.includeDynamicTools) {
|
|
102
|
+
includedTools = dynamicTools(includedTools);
|
|
103
|
+
}
|
|
104
|
+
} else {
|
|
105
|
+
if (options.includeAllTools) {
|
|
106
|
+
includedTools = endpoints;
|
|
107
|
+
} else if (options.includeDynamicTools) {
|
|
108
|
+
includedTools = dynamicTools(endpoints);
|
|
109
|
+
} else {
|
|
110
|
+
includedTools = endpoints;
|
|
111
|
+
}
|
|
84
112
|
}
|
|
85
113
|
|
|
86
|
-
|
|
114
|
+
const capabilities = { ...defaultClientCapabilities, ...options.capabilities };
|
|
115
|
+
return applyCompatibilityTransformations(includedTools, capabilities);
|
|
87
116
|
}
|
|
88
117
|
|
|
89
118
|
/**
|
package/src/tools/index.ts
CHANGED
|
@@ -18,6 +18,7 @@ import delete_testcases from './testcases/delete-testcases';
|
|
|
18
18
|
import get_testcases from './testcases/get-testcases';
|
|
19
19
|
import create_runs from './runs/create-runs';
|
|
20
20
|
import create_metrics from './metrics/create-metrics';
|
|
21
|
+
import update_metrics from './metrics/update-metrics';
|
|
21
22
|
import create_records from './records/create-records';
|
|
22
23
|
import upsert_scores from './scores/upsert-scores';
|
|
23
24
|
import create_systems from './systems/create-systems';
|
|
@@ -49,6 +50,7 @@ addEndpoint(delete_testcases);
|
|
|
49
50
|
addEndpoint(get_testcases);
|
|
50
51
|
addEndpoint(create_runs);
|
|
51
52
|
addEndpoint(create_metrics);
|
|
53
|
+
addEndpoint(update_metrics);
|
|
52
54
|
addEndpoint(create_records);
|
|
53
55
|
addEndpoint(upsert_scores);
|
|
54
56
|
addEndpoint(create_systems);
|
|
@@ -84,9 +86,10 @@ export function query(filters: Filter[], endpoints: Endpoint[]): Endpoint[] {
|
|
|
84
86
|
});
|
|
85
87
|
|
|
86
88
|
// Check if any filters didn't match
|
|
87
|
-
|
|
89
|
+
const unmatched = Array.from(unmatchedFilters).filter((f) => f.type === 'tool' || f.type === 'resource');
|
|
90
|
+
if (unmatched.length > 0) {
|
|
88
91
|
throw new Error(
|
|
89
|
-
`The following filters did not match any endpoints: ${
|
|
92
|
+
`The following filters did not match any endpoints: ${unmatched
|
|
90
93
|
.map((f) => `${f.type}=${f.value}`)
|
|
91
94
|
.join(', ')}`,
|
|
92
95
|
);
|
|
@@ -17,7 +17,8 @@ export const metadata: Metadata = {
|
|
|
17
17
|
|
|
18
18
|
export const tool: Tool = {
|
|
19
19
|
name: 'create_metrics',
|
|
20
|
-
description:
|
|
20
|
+
description:
|
|
21
|
+
'Create a new Metric for evaluating system outputs. The structure of a metric depends on the evalType and outputType of the metric.',
|
|
21
22
|
inputSchema: {
|
|
22
23
|
type: 'object',
|
|
23
24
|
anyOf: [
|