scorecard-ai-mcp 2.4.1 → 2.6.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 +38 -1
- package/code-tool-types.d.mts +2 -0
- package/code-tool-types.d.mts.map +1 -1
- package/code-tool-types.d.ts +2 -0
- package/code-tool-types.d.ts.map +1 -1
- package/code-tool.d.mts +45 -3
- package/code-tool.d.mts.map +1 -1
- package/code-tool.d.ts +45 -3
- package/code-tool.d.ts.map +1 -1
- package/code-tool.js +24 -132
- package/code-tool.js.map +1 -1
- package/code-tool.mjs +24 -99
- package/code-tool.mjs.map +1 -1
- package/docs-search-tool.d.mts +12 -6
- package/docs-search-tool.d.mts.map +1 -1
- package/docs-search-tool.d.ts +12 -6
- package/docs-search-tool.d.ts.map +1 -1
- package/docs-search-tool.js +10 -2
- package/docs-search-tool.js.map +1 -1
- package/docs-search-tool.mjs +10 -2
- package/docs-search-tool.mjs.map +1 -1
- package/dynamic-tools.d.mts +1 -1
- package/dynamic-tools.d.ts +1 -1
- package/dynamic-tools.js +1 -1
- package/dynamic-tools.mjs +1 -1
- package/filtering.d.mts +1 -0
- package/filtering.d.mts.map +1 -1
- package/filtering.d.ts +1 -0
- package/filtering.d.ts.map +1 -1
- package/filtering.js +4 -0
- package/filtering.js.map +1 -1
- package/filtering.mjs +3 -0
- package/filtering.mjs.map +1 -1
- package/headers.d.mts.map +1 -1
- package/headers.d.ts.map +1 -1
- package/headers.js +1 -1
- package/headers.js.map +1 -1
- package/headers.mjs +1 -1
- package/headers.mjs.map +1 -1
- package/http.js +2 -2
- package/http.js.map +1 -1
- package/http.mjs +2 -2
- package/http.mjs.map +1 -1
- package/options.d.mts.map +1 -1
- package/options.d.ts.map +1 -1
- package/options.js +6 -3
- package/options.js.map +1 -1
- package/options.mjs +6 -3
- package/options.mjs.map +1 -1
- package/package.json +6 -20
- package/server.js +1 -1
- package/server.mjs +1 -1
- package/src/code-tool-types.ts +5 -1
- package/src/code-tool.ts +34 -121
- package/src/docs-search-tool.ts +14 -3
- package/src/dynamic-tools.ts +1 -1
- package/src/filtering.ts +4 -0
- package/src/headers.ts +3 -1
- package/src/http.ts +2 -2
- package/src/options.ts +10 -3
- package/src/server.ts +1 -1
- package/src/tools/index.ts +2 -0
- package/src/tools/metrics/create-metrics.ts +9 -2
- package/src/tools/metrics/delete-metrics.ts +54 -0
- package/src/tools/metrics/get-metrics.ts +9 -2
- package/src/tools/metrics/list-metrics.ts +9 -2
- package/src/tools/metrics/update-metrics.ts +9 -2
- package/src/tools/projects/create-projects.ts +10 -3
- package/src/tools/projects/list-projects.ts +10 -3
- package/src/tools/records/create-records.ts +10 -3
- package/src/tools/records/delete-records.ts +10 -3
- package/src/tools/records/list-records.ts +10 -3
- package/src/tools/runs/create-runs.ts +10 -3
- package/src/tools/runs/get-runs.ts +10 -3
- package/src/tools/runs/list-runs.ts +10 -3
- package/src/tools/scores/upsert-scores.ts +12 -3
- package/src/tools/systems/delete-systems.ts +10 -3
- package/src/tools/systems/get-systems.ts +10 -3
- package/src/tools/systems/list-systems.ts +10 -3
- package/src/tools/systems/update-systems.ts +10 -3
- package/src/tools/systems/upsert-systems.ts +10 -3
- package/src/tools/systems/versions/get-systems-versions.ts +12 -5
- package/src/tools/systems/versions/upsert-systems-versions.ts +12 -5
- package/src/tools/testcases/create-testcases.ts +10 -3
- package/src/tools/testcases/delete-testcases.ts +10 -3
- package/src/tools/testcases/get-testcases.ts +10 -3
- package/src/tools/testcases/list-testcases.ts +10 -3
- package/src/tools/testcases/update-testcases.ts +10 -3
- package/src/tools/testsets/create-testsets.ts +10 -3
- package/src/tools/testsets/delete-testsets.ts +10 -3
- package/src/tools/testsets/get-testsets.ts +10 -3
- package/src/tools/testsets/list-testsets.ts +10 -3
- package/src/tools/testsets/update-testsets.ts +10 -3
- package/src/tools/types.ts +12 -0
- package/tools/index.d.mts.map +1 -1
- package/tools/index.d.ts.map +1 -1
- package/tools/index.js +2 -0
- package/tools/index.js.map +1 -1
- package/tools/index.mjs +2 -0
- package/tools/index.mjs.map +1 -1
- package/tools/metrics/create-metrics.d.mts +12 -6
- package/tools/metrics/create-metrics.d.mts.map +1 -1
- package/tools/metrics/create-metrics.d.ts +12 -6
- package/tools/metrics/create-metrics.d.ts.map +1 -1
- package/tools/metrics/create-metrics.js +13 -1
- package/tools/metrics/create-metrics.js.map +1 -1
- package/tools/metrics/create-metrics.mjs +11 -2
- package/tools/metrics/create-metrics.mjs.map +1 -1
- package/tools/metrics/delete-metrics.d.mts +51 -0
- package/tools/metrics/delete-metrics.d.mts.map +1 -0
- package/tools/metrics/delete-metrics.d.ts +51 -0
- package/tools/metrics/delete-metrics.d.ts.map +1 -0
- package/tools/metrics/delete-metrics.js +54 -0
- package/tools/metrics/delete-metrics.js.map +1 -0
- package/tools/metrics/delete-metrics.mjs +47 -0
- package/tools/metrics/delete-metrics.mjs.map +1 -0
- package/tools/metrics/get-metrics.d.mts +12 -6
- package/tools/metrics/get-metrics.d.mts.map +1 -1
- package/tools/metrics/get-metrics.d.ts +12 -6
- package/tools/metrics/get-metrics.d.ts.map +1 -1
- package/tools/metrics/get-metrics.js +13 -1
- package/tools/metrics/get-metrics.js.map +1 -1
- package/tools/metrics/get-metrics.mjs +11 -2
- package/tools/metrics/get-metrics.mjs.map +1 -1
- package/tools/metrics/list-metrics.d.mts +12 -6
- package/tools/metrics/list-metrics.d.mts.map +1 -1
- package/tools/metrics/list-metrics.d.ts +12 -6
- package/tools/metrics/list-metrics.d.ts.map +1 -1
- package/tools/metrics/list-metrics.js +13 -1
- package/tools/metrics/list-metrics.js.map +1 -1
- package/tools/metrics/list-metrics.mjs +11 -2
- package/tools/metrics/list-metrics.mjs.map +1 -1
- package/tools/metrics/update-metrics.d.mts +12 -6
- package/tools/metrics/update-metrics.d.mts.map +1 -1
- package/tools/metrics/update-metrics.d.ts +12 -6
- package/tools/metrics/update-metrics.d.ts.map +1 -1
- package/tools/metrics/update-metrics.js +13 -1
- package/tools/metrics/update-metrics.js.map +1 -1
- package/tools/metrics/update-metrics.mjs +11 -2
- package/tools/metrics/update-metrics.mjs.map +1 -1
- package/tools/projects/create-projects.d.mts +12 -6
- package/tools/projects/create-projects.d.mts.map +1 -1
- package/tools/projects/create-projects.d.ts +12 -6
- package/tools/projects/create-projects.d.ts.map +1 -1
- package/tools/projects/create-projects.js +13 -1
- package/tools/projects/create-projects.js.map +1 -1
- package/tools/projects/create-projects.mjs +12 -3
- package/tools/projects/create-projects.mjs.map +1 -1
- package/tools/projects/list-projects.d.mts +12 -6
- package/tools/projects/list-projects.d.mts.map +1 -1
- package/tools/projects/list-projects.d.ts +12 -6
- package/tools/projects/list-projects.d.ts.map +1 -1
- package/tools/projects/list-projects.js +13 -1
- package/tools/projects/list-projects.js.map +1 -1
- package/tools/projects/list-projects.mjs +12 -3
- package/tools/projects/list-projects.mjs.map +1 -1
- package/tools/records/create-records.d.mts +12 -6
- package/tools/records/create-records.d.mts.map +1 -1
- package/tools/records/create-records.d.ts +12 -6
- package/tools/records/create-records.d.ts.map +1 -1
- package/tools/records/create-records.js +13 -1
- package/tools/records/create-records.js.map +1 -1
- package/tools/records/create-records.mjs +12 -3
- package/tools/records/create-records.mjs.map +1 -1
- package/tools/records/delete-records.d.mts +12 -6
- package/tools/records/delete-records.d.mts.map +1 -1
- package/tools/records/delete-records.d.ts +12 -6
- package/tools/records/delete-records.d.ts.map +1 -1
- package/tools/records/delete-records.js +13 -1
- package/tools/records/delete-records.js.map +1 -1
- package/tools/records/delete-records.mjs +12 -3
- package/tools/records/delete-records.mjs.map +1 -1
- package/tools/records/list-records.d.mts +12 -6
- package/tools/records/list-records.d.mts.map +1 -1
- package/tools/records/list-records.d.ts +12 -6
- package/tools/records/list-records.d.ts.map +1 -1
- package/tools/records/list-records.js +13 -1
- package/tools/records/list-records.js.map +1 -1
- package/tools/records/list-records.mjs +12 -3
- package/tools/records/list-records.mjs.map +1 -1
- package/tools/runs/create-runs.d.mts +12 -6
- package/tools/runs/create-runs.d.mts.map +1 -1
- package/tools/runs/create-runs.d.ts +12 -6
- package/tools/runs/create-runs.d.ts.map +1 -1
- package/tools/runs/create-runs.js +13 -1
- package/tools/runs/create-runs.js.map +1 -1
- package/tools/runs/create-runs.mjs +12 -3
- package/tools/runs/create-runs.mjs.map +1 -1
- package/tools/runs/get-runs.d.mts +12 -6
- package/tools/runs/get-runs.d.mts.map +1 -1
- package/tools/runs/get-runs.d.ts +12 -6
- package/tools/runs/get-runs.d.ts.map +1 -1
- package/tools/runs/get-runs.js +13 -1
- package/tools/runs/get-runs.js.map +1 -1
- package/tools/runs/get-runs.mjs +12 -3
- package/tools/runs/get-runs.mjs.map +1 -1
- package/tools/runs/list-runs.d.mts +12 -6
- package/tools/runs/list-runs.d.mts.map +1 -1
- package/tools/runs/list-runs.d.ts +12 -6
- package/tools/runs/list-runs.d.ts.map +1 -1
- package/tools/runs/list-runs.js +13 -1
- package/tools/runs/list-runs.js.map +1 -1
- package/tools/runs/list-runs.mjs +12 -3
- package/tools/runs/list-runs.mjs.map +1 -1
- package/tools/scores/upsert-scores.d.mts +12 -6
- package/tools/scores/upsert-scores.d.mts.map +1 -1
- package/tools/scores/upsert-scores.d.ts +12 -6
- package/tools/scores/upsert-scores.d.ts.map +1 -1
- package/tools/scores/upsert-scores.js +13 -1
- package/tools/scores/upsert-scores.js.map +1 -1
- package/tools/scores/upsert-scores.mjs +12 -3
- package/tools/scores/upsert-scores.mjs.map +1 -1
- package/tools/systems/delete-systems.d.mts +12 -6
- package/tools/systems/delete-systems.d.mts.map +1 -1
- package/tools/systems/delete-systems.d.ts +12 -6
- package/tools/systems/delete-systems.d.ts.map +1 -1
- package/tools/systems/delete-systems.js +13 -1
- package/tools/systems/delete-systems.js.map +1 -1
- package/tools/systems/delete-systems.mjs +12 -3
- package/tools/systems/delete-systems.mjs.map +1 -1
- package/tools/systems/get-systems.d.mts +12 -6
- package/tools/systems/get-systems.d.mts.map +1 -1
- package/tools/systems/get-systems.d.ts +12 -6
- package/tools/systems/get-systems.d.ts.map +1 -1
- package/tools/systems/get-systems.js +13 -1
- package/tools/systems/get-systems.js.map +1 -1
- package/tools/systems/get-systems.mjs +12 -3
- package/tools/systems/get-systems.mjs.map +1 -1
- package/tools/systems/list-systems.d.mts +12 -6
- package/tools/systems/list-systems.d.mts.map +1 -1
- package/tools/systems/list-systems.d.ts +12 -6
- package/tools/systems/list-systems.d.ts.map +1 -1
- package/tools/systems/list-systems.js +13 -1
- package/tools/systems/list-systems.js.map +1 -1
- package/tools/systems/list-systems.mjs +12 -3
- package/tools/systems/list-systems.mjs.map +1 -1
- package/tools/systems/update-systems.d.mts +12 -6
- package/tools/systems/update-systems.d.mts.map +1 -1
- package/tools/systems/update-systems.d.ts +12 -6
- package/tools/systems/update-systems.d.ts.map +1 -1
- package/tools/systems/update-systems.js +13 -1
- package/tools/systems/update-systems.js.map +1 -1
- package/tools/systems/update-systems.mjs +12 -3
- package/tools/systems/update-systems.mjs.map +1 -1
- package/tools/systems/upsert-systems.d.mts +12 -6
- package/tools/systems/upsert-systems.d.mts.map +1 -1
- package/tools/systems/upsert-systems.d.ts +12 -6
- package/tools/systems/upsert-systems.d.ts.map +1 -1
- package/tools/systems/upsert-systems.js +13 -1
- package/tools/systems/upsert-systems.js.map +1 -1
- package/tools/systems/upsert-systems.mjs +12 -3
- package/tools/systems/upsert-systems.mjs.map +1 -1
- package/tools/systems/versions/get-systems-versions.d.mts +12 -6
- package/tools/systems/versions/get-systems-versions.d.mts.map +1 -1
- package/tools/systems/versions/get-systems-versions.d.ts +12 -6
- package/tools/systems/versions/get-systems-versions.d.ts.map +1 -1
- package/tools/systems/versions/get-systems-versions.js +13 -1
- package/tools/systems/versions/get-systems-versions.js.map +1 -1
- package/tools/systems/versions/get-systems-versions.mjs +12 -3
- package/tools/systems/versions/get-systems-versions.mjs.map +1 -1
- package/tools/systems/versions/upsert-systems-versions.d.mts +12 -6
- package/tools/systems/versions/upsert-systems-versions.d.mts.map +1 -1
- package/tools/systems/versions/upsert-systems-versions.d.ts +12 -6
- package/tools/systems/versions/upsert-systems-versions.d.ts.map +1 -1
- package/tools/systems/versions/upsert-systems-versions.js +13 -1
- package/tools/systems/versions/upsert-systems-versions.js.map +1 -1
- package/tools/systems/versions/upsert-systems-versions.mjs +12 -3
- package/tools/systems/versions/upsert-systems-versions.mjs.map +1 -1
- package/tools/testcases/create-testcases.d.mts +12 -6
- package/tools/testcases/create-testcases.d.mts.map +1 -1
- package/tools/testcases/create-testcases.d.ts +12 -6
- package/tools/testcases/create-testcases.d.ts.map +1 -1
- package/tools/testcases/create-testcases.js +13 -1
- package/tools/testcases/create-testcases.js.map +1 -1
- package/tools/testcases/create-testcases.mjs +12 -3
- package/tools/testcases/create-testcases.mjs.map +1 -1
- package/tools/testcases/delete-testcases.d.mts +12 -6
- package/tools/testcases/delete-testcases.d.mts.map +1 -1
- package/tools/testcases/delete-testcases.d.ts +12 -6
- package/tools/testcases/delete-testcases.d.ts.map +1 -1
- package/tools/testcases/delete-testcases.js +13 -1
- package/tools/testcases/delete-testcases.js.map +1 -1
- package/tools/testcases/delete-testcases.mjs +12 -3
- package/tools/testcases/delete-testcases.mjs.map +1 -1
- package/tools/testcases/get-testcases.d.mts +12 -6
- package/tools/testcases/get-testcases.d.mts.map +1 -1
- package/tools/testcases/get-testcases.d.ts +12 -6
- package/tools/testcases/get-testcases.d.ts.map +1 -1
- package/tools/testcases/get-testcases.js +13 -1
- package/tools/testcases/get-testcases.js.map +1 -1
- package/tools/testcases/get-testcases.mjs +12 -3
- package/tools/testcases/get-testcases.mjs.map +1 -1
- package/tools/testcases/list-testcases.d.mts +12 -6
- package/tools/testcases/list-testcases.d.mts.map +1 -1
- package/tools/testcases/list-testcases.d.ts +12 -6
- package/tools/testcases/list-testcases.d.ts.map +1 -1
- package/tools/testcases/list-testcases.js +13 -1
- package/tools/testcases/list-testcases.js.map +1 -1
- package/tools/testcases/list-testcases.mjs +12 -3
- package/tools/testcases/list-testcases.mjs.map +1 -1
- package/tools/testcases/update-testcases.d.mts +12 -6
- package/tools/testcases/update-testcases.d.mts.map +1 -1
- package/tools/testcases/update-testcases.d.ts +12 -6
- package/tools/testcases/update-testcases.d.ts.map +1 -1
- package/tools/testcases/update-testcases.js +13 -1
- package/tools/testcases/update-testcases.js.map +1 -1
- package/tools/testcases/update-testcases.mjs +12 -3
- package/tools/testcases/update-testcases.mjs.map +1 -1
- package/tools/testsets/create-testsets.d.mts +12 -6
- package/tools/testsets/create-testsets.d.mts.map +1 -1
- package/tools/testsets/create-testsets.d.ts +12 -6
- package/tools/testsets/create-testsets.d.ts.map +1 -1
- package/tools/testsets/create-testsets.js +13 -1
- package/tools/testsets/create-testsets.js.map +1 -1
- package/tools/testsets/create-testsets.mjs +12 -3
- package/tools/testsets/create-testsets.mjs.map +1 -1
- package/tools/testsets/delete-testsets.d.mts +12 -6
- package/tools/testsets/delete-testsets.d.mts.map +1 -1
- package/tools/testsets/delete-testsets.d.ts +12 -6
- package/tools/testsets/delete-testsets.d.ts.map +1 -1
- package/tools/testsets/delete-testsets.js +13 -1
- package/tools/testsets/delete-testsets.js.map +1 -1
- package/tools/testsets/delete-testsets.mjs +12 -3
- package/tools/testsets/delete-testsets.mjs.map +1 -1
- package/tools/testsets/get-testsets.d.mts +12 -6
- package/tools/testsets/get-testsets.d.mts.map +1 -1
- package/tools/testsets/get-testsets.d.ts +12 -6
- package/tools/testsets/get-testsets.d.ts.map +1 -1
- package/tools/testsets/get-testsets.js +13 -1
- package/tools/testsets/get-testsets.js.map +1 -1
- package/tools/testsets/get-testsets.mjs +12 -3
- package/tools/testsets/get-testsets.mjs.map +1 -1
- package/tools/testsets/list-testsets.d.mts +12 -6
- package/tools/testsets/list-testsets.d.mts.map +1 -1
- package/tools/testsets/list-testsets.d.ts +12 -6
- package/tools/testsets/list-testsets.d.ts.map +1 -1
- package/tools/testsets/list-testsets.js +13 -1
- package/tools/testsets/list-testsets.js.map +1 -1
- package/tools/testsets/list-testsets.mjs +12 -3
- package/tools/testsets/list-testsets.mjs.map +1 -1
- package/tools/testsets/update-testsets.d.mts +12 -6
- package/tools/testsets/update-testsets.d.mts.map +1 -1
- package/tools/testsets/update-testsets.d.ts +12 -6
- package/tools/testsets/update-testsets.d.ts.map +1 -1
- package/tools/testsets/update-testsets.js +13 -1
- package/tools/testsets/update-testsets.js.map +1 -1
- package/tools/testsets/update-testsets.mjs +12 -3
- package/tools/testsets/update-testsets.mjs.map +1 -1
- package/tools/types.d.mts +1 -0
- package/tools/types.d.mts.map +1 -1
- package/tools/types.d.ts +1 -0
- package/tools/types.d.ts.map +1 -1
- package/tools/types.js +12 -0
- package/tools/types.js.map +1 -1
- package/tools/types.mjs +11 -0
- package/tools/types.mjs.map +1 -1
- package/code-tool-paths.cjs +0 -6
- package/code-tool-paths.cjs.map +0 -1
- package/code-tool-paths.d.cts +0 -2
- package/code-tool-paths.d.cts.map +0 -1
- package/code-tool-worker.d.mts +0 -5
- package/code-tool-worker.d.mts.map +0 -1
- package/code-tool-worker.d.ts +0 -5
- package/code-tool-worker.d.ts.map +0 -1
- package/code-tool-worker.js +0 -45
- package/code-tool-worker.js.map +0 -1
- package/code-tool-worker.mjs +0 -40
- package/code-tool-worker.mjs.map +0 -1
- package/src/code-tool-paths.cts +0 -3
- package/src/code-tool-worker.ts +0 -46
package/README.md
CHANGED
|
@@ -36,12 +36,36 @@ For clients with a configuration JSON, it might look something like this:
|
|
|
36
36
|
}
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
+
### Cursor
|
|
40
|
+
|
|
41
|
+
If you use Cursor, you can install the MCP server by using the button below. You will need to set your environment variables
|
|
42
|
+
in Cursor's `mcp.json`, which can be found in Cursor Settings > Tools & MCP > New MCP Server.
|
|
43
|
+
|
|
44
|
+
[](https://cursor.com/en-US/install-mcp?name=scorecard-ai-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsInNjb3JlY2FyZC1haS1tY3AiXSwiZW52Ijp7IlNDT1JFQ0FSRF9BUElfS0VZIjoiU2V0IHlvdXIgU0NPUkVDQVJEX0FQSV9LRVkgaGVyZS4ifX0)
|
|
45
|
+
|
|
46
|
+
### VS Code
|
|
47
|
+
|
|
48
|
+
If you use MCP, you can install the MCP server by clicking the link below. You will need to set your environment variables
|
|
49
|
+
in VS Code's `mcp.json`, which can be found via Command Palette > MCP: Open User Configuration.
|
|
50
|
+
|
|
51
|
+
[Open VS Code](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22scorecard-ai-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22scorecard-ai-mcp%22%5D%2C%22env%22%3A%7B%22SCORECARD_API_KEY%22%3A%22Set%20your%20SCORECARD_API_KEY%20here.%22%7D%7D)
|
|
52
|
+
|
|
53
|
+
### Claude Code
|
|
54
|
+
|
|
55
|
+
If you use Claude Code, you can install the MCP server by running the command below in your terminal. You will need to set your
|
|
56
|
+
environment variables in Claude Code's `.claude.json`, which can be found in your home directory.
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
claude mcp add --transport stdio scorecard_ai_api --env SCORECARD_API_KEY="Your SCORECARD_API_KEY here." -- npx -y scorecard-ai-mcp
|
|
60
|
+
```
|
|
61
|
+
|
|
39
62
|
## Exposing endpoints to your MCP Client
|
|
40
63
|
|
|
41
|
-
There are
|
|
64
|
+
There are three ways to expose endpoints as tools in the MCP server:
|
|
42
65
|
|
|
43
66
|
1. Exposing one tool per endpoint, and filtering as necessary
|
|
44
67
|
2. Exposing a set of tools to dynamically discover and invoke endpoints from the API
|
|
68
|
+
3. Exposing a docs search tool and a code execution tool, allowing the client to write code to be executed against the TypeScript client
|
|
45
69
|
|
|
46
70
|
### Filtering endpoints and tools
|
|
47
71
|
|
|
@@ -76,6 +100,18 @@ All of these command-line options can be repeated, combined together, and have c
|
|
|
76
100
|
|
|
77
101
|
Use `--list` to see the list of available tools, or see below.
|
|
78
102
|
|
|
103
|
+
### Code execution
|
|
104
|
+
|
|
105
|
+
If you specify `--tools=code` to the MCP server, it will expose just two tools:
|
|
106
|
+
|
|
107
|
+
- `search_docs` - Searches the API documentation and returns a list of markdown results
|
|
108
|
+
- `execute` - Runs code against the TypeScript client
|
|
109
|
+
|
|
110
|
+
This allows the LLM to implement more complex logic by chaining together many API calls without loading
|
|
111
|
+
intermediary results into its context window.
|
|
112
|
+
|
|
113
|
+
The code execution itself happens in a Deno sandbox that has network access only to the base URL for the API.
|
|
114
|
+
|
|
79
115
|
### Specifying the MCP Client
|
|
80
116
|
|
|
81
117
|
Different clients have varying abilities to handle arbitrary tools and schemas.
|
|
@@ -247,6 +283,7 @@ The following tools are available in this MCP server.
|
|
|
247
283
|
- `create_metrics` (`write`): Create a new Metric for evaluating system outputs. The structure of a metric depends on the evalType and outputType of the metric.
|
|
248
284
|
- `update_metrics` (`write`): Update an existing Metric. You must specify the evalType and outputType of the metric. The structure of a metric depends on the evalType and outputType of the metric.
|
|
249
285
|
- `list_metrics` (`read`): List Metrics configured for the specified Project. Metrics are returned in reverse chronological order.
|
|
286
|
+
- `delete_metrics` (`write`): Delete a specific Metric by ID. The metric will be removed from metric groups and monitors.
|
|
250
287
|
- `get_metrics` (`read`): Retrieve a specific Metric by ID.
|
|
251
288
|
|
|
252
289
|
### Resource `records`:
|
package/code-tool-types.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-tool-types.d.mts","sourceRoot":"","sources":["src/code-tool-types.ts"],"names":[],"mappings":"OAEO,EAAE,aAAa,EAAE,MAAM,cAAc;AAE5C,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,aAAa,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AACF,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACvB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB,CAAC;AACF,MAAM,MAAM,WAAW,GAAG;
|
|
1
|
+
{"version":3,"file":"code-tool-types.d.mts","sourceRoot":"","sources":["src/code-tool-types.ts"],"names":[],"mappings":"OAEO,EAAE,aAAa,EAAE,MAAM,cAAc;AAE5C,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,aAAa,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AACF,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACvB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB,CAAC;AACF,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB,CAAC"}
|
package/code-tool-types.d.ts
CHANGED
package/code-tool-types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-tool-types.d.ts","sourceRoot":"","sources":["src/code-tool-types.ts"],"names":[],"mappings":"OAEO,EAAE,aAAa,EAAE,MAAM,cAAc;AAE5C,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,aAAa,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AACF,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACvB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB,CAAC;AACF,MAAM,MAAM,WAAW,GAAG;
|
|
1
|
+
{"version":3,"file":"code-tool-types.d.ts","sourceRoot":"","sources":["src/code-tool-types.ts"],"names":[],"mappings":"OAEO,EAAE,aAAa,EAAE,MAAM,cAAc;AAE5C,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,aAAa,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AACF,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACvB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB,CAAC;AACF,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB,CAAC"}
|
package/code-tool.d.mts
CHANGED
|
@@ -1,12 +1,54 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Metadata, ToolCallResult } from "./tools/types.mjs";
|
|
2
2
|
/**
|
|
3
3
|
* A tool that runs code against a copy of the SDK.
|
|
4
4
|
*
|
|
5
|
-
* Instead of exposing every endpoint as
|
|
5
|
+
* Instead of exposing every endpoint as its own tool, which uses up too many tokens for LLMs to use at once,
|
|
6
6
|
* we expose a single tool that can be used to search for endpoints by name, resource, operation, or tag, and then
|
|
7
7
|
* a generic endpoint that can be used to invoke any endpoint with the provided arguments.
|
|
8
8
|
*
|
|
9
9
|
* @param endpoints - The endpoints to include in the list.
|
|
10
10
|
*/
|
|
11
|
-
export declare function codeTool(): Promise<
|
|
11
|
+
export declare function codeTool(): Promise<{
|
|
12
|
+
metadata: Metadata;
|
|
13
|
+
tool: {
|
|
14
|
+
inputSchema: {
|
|
15
|
+
[x: string]: unknown;
|
|
16
|
+
type: "object";
|
|
17
|
+
properties?: {
|
|
18
|
+
[x: string]: object;
|
|
19
|
+
} | undefined;
|
|
20
|
+
required?: string[] | undefined;
|
|
21
|
+
};
|
|
22
|
+
name: string;
|
|
23
|
+
description?: string | undefined;
|
|
24
|
+
outputSchema?: {
|
|
25
|
+
[x: string]: unknown;
|
|
26
|
+
type: "object";
|
|
27
|
+
properties?: {
|
|
28
|
+
[x: string]: object;
|
|
29
|
+
} | undefined;
|
|
30
|
+
required?: string[] | undefined;
|
|
31
|
+
} | undefined;
|
|
32
|
+
annotations?: {
|
|
33
|
+
title?: string | undefined;
|
|
34
|
+
readOnlyHint?: boolean | undefined;
|
|
35
|
+
destructiveHint?: boolean | undefined;
|
|
36
|
+
idempotentHint?: boolean | undefined;
|
|
37
|
+
openWorldHint?: boolean | undefined;
|
|
38
|
+
} | undefined;
|
|
39
|
+
execution?: {
|
|
40
|
+
taskSupport?: "optional" | "required" | "forbidden" | undefined;
|
|
41
|
+
} | undefined;
|
|
42
|
+
_meta?: {
|
|
43
|
+
[x: string]: unknown;
|
|
44
|
+
} | undefined;
|
|
45
|
+
icons?: {
|
|
46
|
+
src: string;
|
|
47
|
+
mimeType?: string | undefined;
|
|
48
|
+
sizes?: string[] | undefined;
|
|
49
|
+
}[] | undefined;
|
|
50
|
+
title?: string | undefined;
|
|
51
|
+
};
|
|
52
|
+
handler: (_: unknown, args: any) => Promise<ToolCallResult>;
|
|
53
|
+
}>;
|
|
12
54
|
//# sourceMappingURL=code-tool.d.mts.map
|
package/code-tool.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-tool.d.mts","sourceRoot":"","sources":["src/code-tool.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"code-tool.d.mts","sourceRoot":"","sources":["src/code-tool.ts"],"names":[],"mappings":"OAEO,EAAE,QAAQ,EAAE,cAAc,EAAuB;AAIxD;;;;;;;;GAQG;AACH,wBAAsB,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAQF,OAAO,QAAQ,GAAG,KAAG,OAAO,CAAC,cAAc,CAAC;GAmCvE"}
|
package/code-tool.d.ts
CHANGED
|
@@ -1,12 +1,54 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Metadata, ToolCallResult } from "./tools/types.js";
|
|
2
2
|
/**
|
|
3
3
|
* A tool that runs code against a copy of the SDK.
|
|
4
4
|
*
|
|
5
|
-
* Instead of exposing every endpoint as
|
|
5
|
+
* Instead of exposing every endpoint as its own tool, which uses up too many tokens for LLMs to use at once,
|
|
6
6
|
* we expose a single tool that can be used to search for endpoints by name, resource, operation, or tag, and then
|
|
7
7
|
* a generic endpoint that can be used to invoke any endpoint with the provided arguments.
|
|
8
8
|
*
|
|
9
9
|
* @param endpoints - The endpoints to include in the list.
|
|
10
10
|
*/
|
|
11
|
-
export declare function codeTool(): Promise<
|
|
11
|
+
export declare function codeTool(): Promise<{
|
|
12
|
+
metadata: Metadata;
|
|
13
|
+
tool: {
|
|
14
|
+
inputSchema: {
|
|
15
|
+
[x: string]: unknown;
|
|
16
|
+
type: "object";
|
|
17
|
+
properties?: {
|
|
18
|
+
[x: string]: object;
|
|
19
|
+
} | undefined;
|
|
20
|
+
required?: string[] | undefined;
|
|
21
|
+
};
|
|
22
|
+
name: string;
|
|
23
|
+
description?: string | undefined;
|
|
24
|
+
outputSchema?: {
|
|
25
|
+
[x: string]: unknown;
|
|
26
|
+
type: "object";
|
|
27
|
+
properties?: {
|
|
28
|
+
[x: string]: object;
|
|
29
|
+
} | undefined;
|
|
30
|
+
required?: string[] | undefined;
|
|
31
|
+
} | undefined;
|
|
32
|
+
annotations?: {
|
|
33
|
+
title?: string | undefined;
|
|
34
|
+
readOnlyHint?: boolean | undefined;
|
|
35
|
+
destructiveHint?: boolean | undefined;
|
|
36
|
+
idempotentHint?: boolean | undefined;
|
|
37
|
+
openWorldHint?: boolean | undefined;
|
|
38
|
+
} | undefined;
|
|
39
|
+
execution?: {
|
|
40
|
+
taskSupport?: "optional" | "required" | "forbidden" | undefined;
|
|
41
|
+
} | undefined;
|
|
42
|
+
_meta?: {
|
|
43
|
+
[x: string]: unknown;
|
|
44
|
+
} | undefined;
|
|
45
|
+
icons?: {
|
|
46
|
+
src: string;
|
|
47
|
+
mimeType?: string | undefined;
|
|
48
|
+
sizes?: string[] | undefined;
|
|
49
|
+
}[] | undefined;
|
|
50
|
+
title?: string | undefined;
|
|
51
|
+
};
|
|
52
|
+
handler: (_: unknown, args: any) => Promise<ToolCallResult>;
|
|
53
|
+
}>;
|
|
12
54
|
//# sourceMappingURL=code-tool.d.ts.map
|
package/code-tool.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-tool.d.ts","sourceRoot":"","sources":["src/code-tool.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"code-tool.d.ts","sourceRoot":"","sources":["src/code-tool.ts"],"names":[],"mappings":"OAEO,EAAE,QAAQ,EAAE,cAAc,EAAuB;AAIxD;;;;;;;;GAQG;AACH,wBAAsB,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAQF,OAAO,QAAQ,GAAG,KAAG,OAAO,CAAC,cAAc,CAAC;GAmCvE"}
|
package/code-tool.js
CHANGED
|
@@ -1,46 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
3
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
-
if (k2 === undefined) k2 = k;
|
|
5
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
-
}
|
|
9
|
-
Object.defineProperty(o, k2, desc);
|
|
10
|
-
}) : (function(o, m, k, k2) {
|
|
11
|
-
if (k2 === undefined) k2 = k;
|
|
12
|
-
o[k2] = m[k];
|
|
13
|
-
}));
|
|
14
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
-
}) : function(o, v) {
|
|
17
|
-
o["default"] = v;
|
|
18
|
-
});
|
|
19
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
-
var ownKeys = function(o) {
|
|
21
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
-
var ar = [];
|
|
23
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
-
return ar;
|
|
25
|
-
};
|
|
26
|
-
return ownKeys(o);
|
|
27
|
-
};
|
|
28
|
-
return function (mod) {
|
|
29
|
-
if (mod && mod.__esModule) return mod;
|
|
30
|
-
var result = {};
|
|
31
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
-
__setModuleDefault(result, mod);
|
|
33
|
-
return result;
|
|
34
|
-
};
|
|
35
|
-
})();
|
|
36
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
4
|
exports.codeTool = codeTool;
|
|
38
|
-
const
|
|
39
|
-
const
|
|
5
|
+
const types_1 = require("./tools/types.js");
|
|
6
|
+
const server_1 = require("./server.js");
|
|
40
7
|
/**
|
|
41
8
|
* A tool that runs code against a copy of the SDK.
|
|
42
9
|
*
|
|
43
|
-
* Instead of exposing every endpoint as
|
|
10
|
+
* Instead of exposing every endpoint as its own tool, which uses up too many tokens for LLMs to use at once,
|
|
44
11
|
* we expose a single tool that can be used to search for endpoints by name, resource, operation, or tag, and then
|
|
45
12
|
* a generic endpoint that can be used to invoke any endpoint with the provided arguments.
|
|
46
13
|
*
|
|
@@ -50,107 +17,32 @@ async function codeTool() {
|
|
|
50
17
|
const metadata = { resource: 'all', operation: 'write', tags: [] };
|
|
51
18
|
const tool = {
|
|
52
19
|
name: 'execute',
|
|
53
|
-
description: 'Runs
|
|
20
|
+
description: 'Runs JavaScript code to interact with the API.\n\nYou are a skilled programmer writing code to interface with the service.\nDefine an async function named "run" that takes a single parameter of an initialized SDK client and it will be run.\nWrite code within this template:\n\n```\nasync function run(client) {\n // Fill this out\n}\n```\n\nYou will be returned anything that your function returns, plus the results of any console.log statements.\nIf any code triggers an error, the tool will return an error response, so you do not need to add error handling unless you want to output something more helpful than the raw error.\nIt is not necessary to add comments to code, unless by adding those comments you believe that you can generate better code.\nThis code will run in a container, and you will not be able to use fetch or otherwise interact with the network calls other than through the client you are given.\nAny variables you define won\'t live between successive uses of this call, so make sure to return or log any data you might need later.',
|
|
54
21
|
inputSchema: { type: 'object', properties: { code: { type: 'string' } } },
|
|
55
22
|
};
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const
|
|
61
|
-
const
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
// even though they are not set.
|
|
69
|
-
'--allow-env',
|
|
70
|
-
],
|
|
71
|
-
printOutput: true,
|
|
72
|
-
spawnOptions: {
|
|
73
|
-
cwd: (0, node_path_1.dirname)(workerPath),
|
|
23
|
+
const handler = async (_, args) => {
|
|
24
|
+
const code = args.code;
|
|
25
|
+
// this is not required, but passing a Stainless API key for the matching project_name
|
|
26
|
+
// will allow you to run code-mode queries against non-published versions of your SDK.
|
|
27
|
+
const stainlessAPIKey = (0, server_1.readEnv)('STAINLESS_API_KEY');
|
|
28
|
+
const codeModeEndpoint = (0, server_1.readEnv)('CODE_MODE_ENDPOINT_URL') ?? 'https://api.stainless.com/api/ai/code-tool';
|
|
29
|
+
const res = await fetch(codeModeEndpoint, {
|
|
30
|
+
method: 'POST',
|
|
31
|
+
headers: {
|
|
32
|
+
...(stainlessAPIKey && { Authorization: stainlessAPIKey }),
|
|
33
|
+
'Content-Type': 'application/json',
|
|
34
|
+
client_envs: JSON.stringify({ SCORECARD_API_KEY: (0, server_1.readEnv)('SCORECARD_API_KEY') }),
|
|
74
35
|
},
|
|
36
|
+
body: JSON.stringify({
|
|
37
|
+
project_name: 'scorecard',
|
|
38
|
+
client_opts: { environment: ((0, server_1.readEnv)('SCORECARD_ENVIRONMENT') || undefined) },
|
|
39
|
+
code,
|
|
40
|
+
}),
|
|
75
41
|
});
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
worker.addEventListener('exit', (exitCode) => {
|
|
79
|
-
reject(new Error(`Worker exited with code ${exitCode}`));
|
|
80
|
-
});
|
|
81
|
-
const opts = {
|
|
82
|
-
baseURL: client.baseURL,
|
|
83
|
-
apiKey: client.apiKey,
|
|
84
|
-
defaultHeaders: {
|
|
85
|
-
'X-Stainless-MCP': 'true',
|
|
86
|
-
},
|
|
87
|
-
};
|
|
88
|
-
const req = worker.request('http://localhost', {
|
|
89
|
-
headers: {
|
|
90
|
-
'content-type': 'application/json',
|
|
91
|
-
},
|
|
92
|
-
method: 'POST',
|
|
93
|
-
}, (resp) => {
|
|
94
|
-
const body = [];
|
|
95
|
-
resp.on('error', (err) => {
|
|
96
|
-
reject(err);
|
|
97
|
-
});
|
|
98
|
-
resp.on('data', (chunk) => {
|
|
99
|
-
body.push(chunk);
|
|
100
|
-
});
|
|
101
|
-
resp.on('end', () => {
|
|
102
|
-
resolve(new Response(Buffer.concat(body).toString(), {
|
|
103
|
-
status: resp.statusCode ?? 200,
|
|
104
|
-
headers: resp.headers,
|
|
105
|
-
}));
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
const body = JSON.stringify({
|
|
109
|
-
opts,
|
|
110
|
-
code,
|
|
111
|
-
});
|
|
112
|
-
req.write(body, (err) => {
|
|
113
|
-
if (err !== null && err !== undefined) {
|
|
114
|
-
reject(err);
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
req.end();
|
|
118
|
-
});
|
|
119
|
-
if (resp.status === 200) {
|
|
120
|
-
const { result, logLines, errLines } = (await resp.json());
|
|
121
|
-
const returnOutput = result === null ? null
|
|
122
|
-
: result === undefined ? null
|
|
123
|
-
: {
|
|
124
|
-
type: 'text',
|
|
125
|
-
text: typeof result === 'string' ? result : JSON.stringify(result),
|
|
126
|
-
};
|
|
127
|
-
const logOutput = logLines.length === 0 ?
|
|
128
|
-
null
|
|
129
|
-
: {
|
|
130
|
-
type: 'text',
|
|
131
|
-
text: logLines.join('\n'),
|
|
132
|
-
};
|
|
133
|
-
const errOutput = errLines.length === 0 ?
|
|
134
|
-
null
|
|
135
|
-
: {
|
|
136
|
-
type: 'text',
|
|
137
|
-
text: 'Error output:\n' + errLines.join('\n'),
|
|
138
|
-
};
|
|
139
|
-
return {
|
|
140
|
-
content: [returnOutput, logOutput, errOutput].filter((block) => block !== null),
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
else {
|
|
144
|
-
const { message } = (await resp.json());
|
|
145
|
-
throw new Error(message);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
catch (e) {
|
|
149
|
-
throw e;
|
|
150
|
-
}
|
|
151
|
-
finally {
|
|
152
|
-
worker.terminate();
|
|
42
|
+
if (!res.ok) {
|
|
43
|
+
throw new Error(`${res.status}: ${res.statusText} error when trying to contact Code Tool server. Details: ${await res.text()}`);
|
|
153
44
|
}
|
|
45
|
+
return (0, types_1.asTextContentResult)((await res.json()));
|
|
154
46
|
};
|
|
155
47
|
return { metadata, tool, handler };
|
|
156
48
|
}
|
package/code-tool.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-tool.js","sourceRoot":"","sources":["src/code-tool.ts"],"names":[],"mappings":";AAAA,sFAAsF
|
|
1
|
+
{"version":3,"file":"code-tool.js","sourceRoot":"","sources":["src/code-tool.ts"],"names":[],"mappings":";AAAA,sFAAsF;;AAetF,4BA2CC;AAxDD,4CAA8E;AAE9E,wCAAmC;AAEnC;;;;;;;;GAQG;AACI,KAAK,UAAU,QAAQ;IAC5B,MAAM,QAAQ,GAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;IAC7E,MAAM,IAAI,GAAS;QACjB,IAAI,EAAE,SAAS;QACf,WAAW,EACT,iiCAAiiC;QACniC,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE;KAC1E,CAAC;IACF,MAAM,OAAO,GAAG,KAAK,EAAE,CAAU,EAAE,IAAS,EAA2B,EAAE;QACvE,MAAM,IAAI,GAAG,IAAI,CAAC,IAAc,CAAC;QAEjC,sFAAsF;QACtF,sFAAsF;QACtF,MAAM,eAAe,GAAG,IAAA,gBAAO,EAAC,mBAAmB,CAAC,CAAC;QACrD,MAAM,gBAAgB,GACpB,IAAA,gBAAO,EAAC,wBAAwB,CAAC,IAAI,4CAA4C,CAAC;QAEpF,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,gBAAgB,EAAE;YACxC,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,GAAG,CAAC,eAAe,IAAI,EAAE,aAAa,EAAE,eAAe,EAAE,CAAC;gBAC1D,cAAc,EAAE,kBAAkB;gBAClC,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,iBAAiB,EAAE,IAAA,gBAAO,EAAC,mBAAmB,CAAC,EAAE,CAAC;aACjF;YACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;gBACnB,YAAY,EAAE,WAAW;gBACzB,WAAW,EAAE,EAAE,WAAW,EAAE,CAAC,IAAA,gBAAO,EAAC,uBAAuB,CAAC,IAAI,SAAS,CAAQ,EAAE;gBACpF,IAAI;aACL,CAAC;SACH,CAAC,CAAC;QAEH,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CACb,GAAG,GAAG,CAAC,MAAM,KACX,GAAG,CAAC,UACN,4DAA4D,MAAM,GAAG,CAAC,IAAI,EAAE,EAAE,CAC/E,CAAC;QACJ,CAAC;QAED,OAAO,IAAA,2BAAmB,EAAC,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAkB,CAAC,CAAC;IAClE,CAAC,CAAC;IAEF,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AACrC,CAAC"}
|
package/code-tool.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { asTextContentResult } from "./tools/types.mjs";
|
|
3
|
+
import { readEnv } from "./server.mjs";
|
|
4
4
|
/**
|
|
5
5
|
* A tool that runs code against a copy of the SDK.
|
|
6
6
|
*
|
|
7
|
-
* Instead of exposing every endpoint as
|
|
7
|
+
* Instead of exposing every endpoint as its own tool, which uses up too many tokens for LLMs to use at once,
|
|
8
8
|
* we expose a single tool that can be used to search for endpoints by name, resource, operation, or tag, and then
|
|
9
9
|
* a generic endpoint that can be used to invoke any endpoint with the provided arguments.
|
|
10
10
|
*
|
|
@@ -14,107 +14,32 @@ export async function codeTool() {
|
|
|
14
14
|
const metadata = { resource: 'all', operation: 'write', tags: [] };
|
|
15
15
|
const tool = {
|
|
16
16
|
name: 'execute',
|
|
17
|
-
description: 'Runs
|
|
17
|
+
description: 'Runs JavaScript code to interact with the API.\n\nYou are a skilled programmer writing code to interface with the service.\nDefine an async function named "run" that takes a single parameter of an initialized SDK client and it will be run.\nWrite code within this template:\n\n```\nasync function run(client) {\n // Fill this out\n}\n```\n\nYou will be returned anything that your function returns, plus the results of any console.log statements.\nIf any code triggers an error, the tool will return an error response, so you do not need to add error handling unless you want to output something more helpful than the raw error.\nIt is not necessary to add comments to code, unless by adding those comments you believe that you can generate better code.\nThis code will run in a container, and you will not be able to use fetch or otherwise interact with the network calls other than through the client you are given.\nAny variables you define won\'t live between successive uses of this call, so make sure to return or log any data you might need later.',
|
|
18
18
|
inputSchema: { type: 'object', properties: { code: { type: 'string' } } },
|
|
19
19
|
};
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
// even though they are not set.
|
|
33
|
-
'--allow-env',
|
|
34
|
-
],
|
|
35
|
-
printOutput: true,
|
|
36
|
-
spawnOptions: {
|
|
37
|
-
cwd: dirname(workerPath),
|
|
20
|
+
const handler = async (_, args) => {
|
|
21
|
+
const code = args.code;
|
|
22
|
+
// this is not required, but passing a Stainless API key for the matching project_name
|
|
23
|
+
// will allow you to run code-mode queries against non-published versions of your SDK.
|
|
24
|
+
const stainlessAPIKey = readEnv('STAINLESS_API_KEY');
|
|
25
|
+
const codeModeEndpoint = readEnv('CODE_MODE_ENDPOINT_URL') ?? 'https://api.stainless.com/api/ai/code-tool';
|
|
26
|
+
const res = await fetch(codeModeEndpoint, {
|
|
27
|
+
method: 'POST',
|
|
28
|
+
headers: {
|
|
29
|
+
...(stainlessAPIKey && { Authorization: stainlessAPIKey }),
|
|
30
|
+
'Content-Type': 'application/json',
|
|
31
|
+
client_envs: JSON.stringify({ SCORECARD_API_KEY: readEnv('SCORECARD_API_KEY') }),
|
|
38
32
|
},
|
|
33
|
+
body: JSON.stringify({
|
|
34
|
+
project_name: 'scorecard',
|
|
35
|
+
client_opts: { environment: (readEnv('SCORECARD_ENVIRONMENT') || undefined) },
|
|
36
|
+
code,
|
|
37
|
+
}),
|
|
39
38
|
});
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
worker.addEventListener('exit', (exitCode) => {
|
|
43
|
-
reject(new Error(`Worker exited with code ${exitCode}`));
|
|
44
|
-
});
|
|
45
|
-
const opts = {
|
|
46
|
-
baseURL: client.baseURL,
|
|
47
|
-
apiKey: client.apiKey,
|
|
48
|
-
defaultHeaders: {
|
|
49
|
-
'X-Stainless-MCP': 'true',
|
|
50
|
-
},
|
|
51
|
-
};
|
|
52
|
-
const req = worker.request('http://localhost', {
|
|
53
|
-
headers: {
|
|
54
|
-
'content-type': 'application/json',
|
|
55
|
-
},
|
|
56
|
-
method: 'POST',
|
|
57
|
-
}, (resp) => {
|
|
58
|
-
const body = [];
|
|
59
|
-
resp.on('error', (err) => {
|
|
60
|
-
reject(err);
|
|
61
|
-
});
|
|
62
|
-
resp.on('data', (chunk) => {
|
|
63
|
-
body.push(chunk);
|
|
64
|
-
});
|
|
65
|
-
resp.on('end', () => {
|
|
66
|
-
resolve(new Response(Buffer.concat(body).toString(), {
|
|
67
|
-
status: resp.statusCode ?? 200,
|
|
68
|
-
headers: resp.headers,
|
|
69
|
-
}));
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
const body = JSON.stringify({
|
|
73
|
-
opts,
|
|
74
|
-
code,
|
|
75
|
-
});
|
|
76
|
-
req.write(body, (err) => {
|
|
77
|
-
if (err !== null && err !== undefined) {
|
|
78
|
-
reject(err);
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
req.end();
|
|
82
|
-
});
|
|
83
|
-
if (resp.status === 200) {
|
|
84
|
-
const { result, logLines, errLines } = (await resp.json());
|
|
85
|
-
const returnOutput = result === null ? null
|
|
86
|
-
: result === undefined ? null
|
|
87
|
-
: {
|
|
88
|
-
type: 'text',
|
|
89
|
-
text: typeof result === 'string' ? result : JSON.stringify(result),
|
|
90
|
-
};
|
|
91
|
-
const logOutput = logLines.length === 0 ?
|
|
92
|
-
null
|
|
93
|
-
: {
|
|
94
|
-
type: 'text',
|
|
95
|
-
text: logLines.join('\n'),
|
|
96
|
-
};
|
|
97
|
-
const errOutput = errLines.length === 0 ?
|
|
98
|
-
null
|
|
99
|
-
: {
|
|
100
|
-
type: 'text',
|
|
101
|
-
text: 'Error output:\n' + errLines.join('\n'),
|
|
102
|
-
};
|
|
103
|
-
return {
|
|
104
|
-
content: [returnOutput, logOutput, errOutput].filter((block) => block !== null),
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
else {
|
|
108
|
-
const { message } = (await resp.json());
|
|
109
|
-
throw new Error(message);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
catch (e) {
|
|
113
|
-
throw e;
|
|
114
|
-
}
|
|
115
|
-
finally {
|
|
116
|
-
worker.terminate();
|
|
39
|
+
if (!res.ok) {
|
|
40
|
+
throw new Error(`${res.status}: ${res.statusText} error when trying to contact Code Tool server. Details: ${await res.text()}`);
|
|
117
41
|
}
|
|
42
|
+
return asTextContentResult((await res.json()));
|
|
118
43
|
};
|
|
119
44
|
return { metadata, tool, handler };
|
|
120
45
|
}
|
package/code-tool.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-tool.mjs","sourceRoot":"","sources":["src/code-tool.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,
|
|
1
|
+
{"version":3,"file":"code-tool.mjs","sourceRoot":"","sources":["src/code-tool.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAA4B,mBAAmB,EAAE;OAEjD,EAAE,OAAO,EAAE;AAElB;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ;IAC5B,MAAM,QAAQ,GAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;IAC7E,MAAM,IAAI,GAAS;QACjB,IAAI,EAAE,SAAS;QACf,WAAW,EACT,iiCAAiiC;QACniC,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE;KAC1E,CAAC;IACF,MAAM,OAAO,GAAG,KAAK,EAAE,CAAU,EAAE,IAAS,EAA2B,EAAE;QACvE,MAAM,IAAI,GAAG,IAAI,CAAC,IAAc,CAAC;QAEjC,sFAAsF;QACtF,sFAAsF;QACtF,MAAM,eAAe,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;QACrD,MAAM,gBAAgB,GACpB,OAAO,CAAC,wBAAwB,CAAC,IAAI,4CAA4C,CAAC;QAEpF,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,gBAAgB,EAAE;YACxC,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,GAAG,CAAC,eAAe,IAAI,EAAE,aAAa,EAAE,eAAe,EAAE,CAAC;gBAC1D,cAAc,EAAE,kBAAkB;gBAClC,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,iBAAiB,EAAE,OAAO,CAAC,mBAAmB,CAAC,EAAE,CAAC;aACjF;YACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;gBACnB,YAAY,EAAE,WAAW;gBACzB,WAAW,EAAE,EAAE,WAAW,EAAE,CAAC,OAAO,CAAC,uBAAuB,CAAC,IAAI,SAAS,CAAQ,EAAE;gBACpF,IAAI;aACL,CAAC;SACH,CAAC,CAAC;QAEH,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CACb,GAAG,GAAG,CAAC,MAAM,KACX,GAAG,CAAC,UACN,4DAA4D,MAAM,GAAG,CAAC,IAAI,EAAE,EAAE,CAC/E,CAAC;QACJ,CAAC;QAED,OAAO,mBAAmB,CAAC,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAkB,CAAC,CAAC;IAClE,CAAC,CAAC;IAEF,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AACrC,CAAC"}
|
package/docs-search-tool.d.mts
CHANGED
|
@@ -6,37 +6,43 @@ export declare const handler: (_: unknown, args: Record<string, unknown> | undef
|
|
|
6
6
|
declare const _default: {
|
|
7
7
|
metadata: Metadata;
|
|
8
8
|
tool: {
|
|
9
|
-
[x: string]: unknown;
|
|
10
|
-
name: string;
|
|
11
9
|
inputSchema: {
|
|
12
10
|
[x: string]: unknown;
|
|
13
11
|
type: "object";
|
|
14
12
|
properties?: {
|
|
15
|
-
[x: string]:
|
|
13
|
+
[x: string]: object;
|
|
16
14
|
} | undefined;
|
|
17
15
|
required?: string[] | undefined;
|
|
18
16
|
};
|
|
19
|
-
|
|
17
|
+
name: string;
|
|
20
18
|
description?: string | undefined;
|
|
21
19
|
outputSchema?: {
|
|
22
20
|
[x: string]: unknown;
|
|
23
21
|
type: "object";
|
|
24
22
|
properties?: {
|
|
25
|
-
[x: string]:
|
|
23
|
+
[x: string]: object;
|
|
26
24
|
} | undefined;
|
|
27
25
|
required?: string[] | undefined;
|
|
28
26
|
} | undefined;
|
|
29
27
|
annotations?: {
|
|
30
|
-
[x: string]: unknown;
|
|
31
28
|
title?: string | undefined;
|
|
32
29
|
readOnlyHint?: boolean | undefined;
|
|
33
30
|
destructiveHint?: boolean | undefined;
|
|
34
31
|
idempotentHint?: boolean | undefined;
|
|
35
32
|
openWorldHint?: boolean | undefined;
|
|
36
33
|
} | undefined;
|
|
34
|
+
execution?: {
|
|
35
|
+
taskSupport?: "optional" | "required" | "forbidden" | undefined;
|
|
36
|
+
} | undefined;
|
|
37
37
|
_meta?: {
|
|
38
38
|
[x: string]: unknown;
|
|
39
39
|
} | undefined;
|
|
40
|
+
icons?: {
|
|
41
|
+
src: string;
|
|
42
|
+
mimeType?: string | undefined;
|
|
43
|
+
sizes?: string[] | undefined;
|
|
44
|
+
}[] | undefined;
|
|
45
|
+
title?: string | undefined;
|
|
40
46
|
};
|
|
41
47
|
handler: (_: unknown, args: Record<string, unknown> | undefined) => Promise<import("./tools/types").ToolCallResult>;
|
|
42
48
|
};
|