spotted-ts-mcp 0.15.0 → 0.16.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 +1 -1
- package/code-tool-types.d.mts +6 -9
- package/code-tool-types.d.mts.map +1 -1
- package/code-tool-types.d.ts +6 -9
- package/code-tool-types.d.ts.map +1 -1
- package/code-tool.d.mts.map +1 -1
- package/code-tool.d.ts.map +1 -1
- package/code-tool.js +12 -2
- package/code-tool.js.map +1 -1
- package/code-tool.mjs +13 -3
- package/code-tool.mjs.map +1 -1
- package/package.json +2 -2
- package/server.js +1 -1
- package/server.mjs +1 -1
- package/src/code-tool-types.ts +6 -9
- package/src/code-tool.ts +15 -5
- package/src/server.ts +1 -1
package/README.md
CHANGED
|
@@ -58,7 +58,7 @@ If you use Claude Code, you can install the MCP server by running the command be
|
|
|
58
58
|
environment variables in Claude Code's `.claude.json`, which can be found in your home directory.
|
|
59
59
|
|
|
60
60
|
```
|
|
61
|
-
claude mcp add
|
|
61
|
+
claude mcp add spotted_ts_mcp_api --env SPOTIFY_CLIENT_ID="Your SPOTIFY_CLIENT_ID here." SPOTIFY_CLIENT_SECRET="Your SPOTIFY_CLIENT_SECRET here." SPOTIFY_ACCESS_TOKEN="Your SPOTIFY_ACCESS_TOKEN here." -- npx -y spotted-ts-mcp
|
|
62
62
|
```
|
|
63
63
|
|
|
64
64
|
## Code Mode
|
package/code-tool-types.d.mts
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
import { ClientOptions } from 'spotted-ts';
|
|
2
2
|
export type WorkerInput = {
|
|
3
|
-
|
|
3
|
+
project_name: string;
|
|
4
4
|
code: string;
|
|
5
|
+
client_opts: ClientOptions;
|
|
5
6
|
};
|
|
6
|
-
export type
|
|
7
|
+
export type WorkerOutput = {
|
|
8
|
+
is_error: boolean;
|
|
7
9
|
result: unknown | null;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
-
export type WorkerError = {
|
|
12
|
-
message: string | undefined;
|
|
13
|
-
logLines: string[];
|
|
14
|
-
errLines: string[];
|
|
10
|
+
log_lines: string[];
|
|
11
|
+
err_lines: string[];
|
|
15
12
|
};
|
|
16
13
|
//# sourceMappingURL=code-tool-types.d.mts.map
|
|
@@ -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,YAAY;AAE1C,MAAM,MAAM,WAAW,GAAG;IACxB,
|
|
1
|
+
{"version":3,"file":"code-tool-types.d.mts","sourceRoot":"","sources":["src/code-tool-types.ts"],"names":[],"mappings":"OAEO,EAAE,aAAa,EAAE,MAAM,YAAY;AAE1C,MAAM,MAAM,WAAW,GAAG;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,aAAa,CAAC;CAC5B,CAAC;AACF,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACvB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC"}
|
package/code-tool-types.d.ts
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
import { ClientOptions } from 'spotted-ts';
|
|
2
2
|
export type WorkerInput = {
|
|
3
|
-
|
|
3
|
+
project_name: string;
|
|
4
4
|
code: string;
|
|
5
|
+
client_opts: ClientOptions;
|
|
5
6
|
};
|
|
6
|
-
export type
|
|
7
|
+
export type WorkerOutput = {
|
|
8
|
+
is_error: boolean;
|
|
7
9
|
result: unknown | null;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
-
export type WorkerError = {
|
|
12
|
-
message: string | undefined;
|
|
13
|
-
logLines: string[];
|
|
14
|
-
errLines: string[];
|
|
10
|
+
log_lines: string[];
|
|
11
|
+
err_lines: string[];
|
|
15
12
|
};
|
|
16
13
|
//# sourceMappingURL=code-tool-types.d.ts.map
|
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,YAAY;AAE1C,MAAM,MAAM,WAAW,GAAG;IACxB,
|
|
1
|
+
{"version":3,"file":"code-tool-types.d.ts","sourceRoot":"","sources":["src/code-tool-types.ts"],"names":[],"mappings":"OAEO,EAAE,aAAa,EAAE,MAAM,YAAY;AAE1C,MAAM,MAAM,WAAW,GAAG;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,aAAa,CAAC;CAC5B,CAAC;AACF,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACvB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC"}
|
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":"OAEO,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"code-tool.d.mts","sourceRoot":"","sources":["src/code-tool.ts"],"names":[],"mappings":"OAEO,EAAE,OAAO,EAAgE;AAIhF;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,IAAI,OAAO,CA0DlC"}
|
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":"OAEO,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"code-tool.d.ts","sourceRoot":"","sources":["src/code-tool.ts"],"names":[],"mappings":"OAEO,EAAE,OAAO,EAAgE;AAIhF;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,IAAI,OAAO,CA0DlC"}
|
package/code-tool.js
CHANGED
|
@@ -40,14 +40,24 @@ function codeTool() {
|
|
|
40
40
|
},
|
|
41
41
|
body: JSON.stringify({
|
|
42
42
|
project_name: 'spotted',
|
|
43
|
-
client_opts: {},
|
|
44
43
|
code,
|
|
44
|
+
client_opts: {},
|
|
45
45
|
}),
|
|
46
46
|
});
|
|
47
47
|
if (!res.ok) {
|
|
48
48
|
throw new Error(`${res.status}: ${res.statusText} error when trying to contact Code Tool server. Details: ${await res.text()}`);
|
|
49
49
|
}
|
|
50
|
-
|
|
50
|
+
const { is_error, result, log_lines, err_lines } = (await res.json());
|
|
51
|
+
const hasLogs = log_lines.length > 0 || err_lines.length > 0;
|
|
52
|
+
const output = {
|
|
53
|
+
result,
|
|
54
|
+
...(log_lines.length > 0 && { log_lines }),
|
|
55
|
+
...(err_lines.length > 0 && { err_lines }),
|
|
56
|
+
};
|
|
57
|
+
if (is_error) {
|
|
58
|
+
return (0, types_1.asErrorResult)(typeof result === 'string' && !hasLogs ? result : JSON.stringify(output, null, 2));
|
|
59
|
+
}
|
|
60
|
+
return (0, types_1.asTextContentResult)(output);
|
|
51
61
|
};
|
|
52
62
|
return { metadata, tool, handler };
|
|
53
63
|
}
|
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;;AAetF,
|
|
1
|
+
{"version":3,"file":"code-tool.js","sourceRoot":"","sources":["src/code-tool.ts"],"names":[],"mappings":";AAAA,sFAAsF;;AAetF,4BA0DC;AAvED,sCAAgG;AAEhG,wCAAmC;AAEnC;;;;;;;;GAQG;AACH,SAAgB,QAAQ;IACtB,MAAM,QAAQ,GAAa,EAAE,QAAQ,EAAE,KAAK,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M,IAAI,KAAK,CACb,GAAG,GAAG,CAAC,MAAM,KACX,GAAG,CAAC,UACN,4DAA4D,MAAM,GAAG,CAAC,IAAI,EAAE,EAAE,CAC/E,CAAC;QACJ,CAAC;QAED,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAiB,CAAC;QACtF,MAAM,OAAO,GAAG,SAAS,CAAC,MAAM,GAAG,CAAC,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;QAC7D,MAAM,MAAM,GAAG;YACb,MAAM;YACN,GAAG,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC;YAC1C,GAAG,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC;SAC3C,CAAC;QACF,IAAI,QAAQ,EAAE,CAAC;YACb,OAAO,IAAA,qBAAa,EAAC,OAAO,MAAM,KAAK,QAAQ,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QAC1G,CAAC;QACD,OAAO,IAAA,2BAAmB,EAAC,MAAM,CAAC,CAAC;IACrC,CAAC,CAAC;IAEF,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AACrC,CAAC"}
|
package/code-tool.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
-
import { asTextContentResult } from "./types.mjs";
|
|
2
|
+
import { asErrorResult, asTextContentResult } from "./types.mjs";
|
|
3
3
|
import { readEnv } from "./server.mjs";
|
|
4
4
|
/**
|
|
5
5
|
* A tool that runs code against a copy of the SDK.
|
|
@@ -37,14 +37,24 @@ export function codeTool() {
|
|
|
37
37
|
},
|
|
38
38
|
body: JSON.stringify({
|
|
39
39
|
project_name: 'spotted',
|
|
40
|
-
client_opts: {},
|
|
41
40
|
code,
|
|
41
|
+
client_opts: {},
|
|
42
42
|
}),
|
|
43
43
|
});
|
|
44
44
|
if (!res.ok) {
|
|
45
45
|
throw new Error(`${res.status}: ${res.statusText} error when trying to contact Code Tool server. Details: ${await res.text()}`);
|
|
46
46
|
}
|
|
47
|
-
|
|
47
|
+
const { is_error, result, log_lines, err_lines } = (await res.json());
|
|
48
|
+
const hasLogs = log_lines.length > 0 || err_lines.length > 0;
|
|
49
|
+
const output = {
|
|
50
|
+
result,
|
|
51
|
+
...(log_lines.length > 0 && { log_lines }),
|
|
52
|
+
...(err_lines.length > 0 && { err_lines }),
|
|
53
|
+
};
|
|
54
|
+
if (is_error) {
|
|
55
|
+
return asErrorResult(typeof result === 'string' && !hasLogs ? result : JSON.stringify(output, null, 2));
|
|
56
|
+
}
|
|
57
|
+
return asTextContentResult(output);
|
|
48
58
|
};
|
|
49
59
|
return { metadata, tool, handler };
|
|
50
60
|
}
|
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,EAAqC,mBAAmB,EAAE;
|
|
1
|
+
{"version":3,"file":"code-tool.mjs","sourceRoot":"","sources":["src/code-tool.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAqC,aAAa,EAAE,mBAAmB,EAAE;OAEzE,EAAE,OAAO,EAAE;AAElB;;;;;;;;GAQG;AACH,MAAM,UAAU,QAAQ;IACtB,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;Q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S,EAAE,SAAS,EAAE,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAiB,CAAC;QACtF,MAAM,OAAO,GAAG,SAAS,CAAC,MAAM,GAAG,CAAC,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;QAC7D,MAAM,MAAM,GAAG;YACb,MAAM;YACN,GAAG,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC;YAC1C,GAAG,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC;SAC3C,CAAC;QACF,IAAI,QAAQ,EAAE,CAAC;YACb,OAAO,aAAa,CAAC,OAAO,MAAM,KAAK,QAAQ,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QAC1G,CAAC;QACD,OAAO,mBAAmB,CAAC,MAAM,CAAC,CAAC;IACrC,CAAC,CAAC;IAEF,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AACrC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "spotted-ts-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"description": "The official MCP Server for the Spotted API",
|
|
5
5
|
"author": "Spotted <wave@cjav.dev>",
|
|
6
6
|
"types": "./index.d.ts",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"fix": "eslint --fix --ext ts,js ."
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"spotted-ts": "^0.
|
|
30
|
+
"spotted-ts": "^0.16.0",
|
|
31
31
|
"@cloudflare/cabidela": "^0.2.4",
|
|
32
32
|
"@modelcontextprotocol/sdk": "^1.24.0",
|
|
33
33
|
"@valtown/deno-http-worker": "^0.0.21",
|
package/server.js
CHANGED
|
@@ -15,7 +15,7 @@ const code_tool_1 = require("./code-tool.js");
|
|
|
15
15
|
const docs_search_tool_1 = __importDefault(require("./docs-search-tool.js"));
|
|
16
16
|
const newMcpServer = () => new mcp_js_1.McpServer({
|
|
17
17
|
name: 'spotted_ts_api',
|
|
18
|
-
version: '0.
|
|
18
|
+
version: '0.16.0',
|
|
19
19
|
}, { capabilities: { tools: {}, logging: {} } });
|
|
20
20
|
exports.newMcpServer = newMcpServer;
|
|
21
21
|
// Create server instance
|
package/server.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import { codeTool } from "./code-tool.mjs";
|
|
|
6
6
|
import docsSearchTool from "./docs-search-tool.mjs";
|
|
7
7
|
export const newMcpServer = () => new McpServer({
|
|
8
8
|
name: 'spotted_ts_api',
|
|
9
|
-
version: '0.
|
|
9
|
+
version: '0.16.0',
|
|
10
10
|
}, { capabilities: { tools: {}, logging: {} } });
|
|
11
11
|
// Create server instance
|
|
12
12
|
export const server = newMcpServer();
|
package/src/code-tool-types.ts
CHANGED
|
@@ -3,16 +3,13 @@
|
|
|
3
3
|
import { ClientOptions } from 'spotted-ts';
|
|
4
4
|
|
|
5
5
|
export type WorkerInput = {
|
|
6
|
-
|
|
6
|
+
project_name: string;
|
|
7
7
|
code: string;
|
|
8
|
+
client_opts: ClientOptions;
|
|
8
9
|
};
|
|
9
|
-
export type
|
|
10
|
+
export type WorkerOutput = {
|
|
11
|
+
is_error: boolean;
|
|
10
12
|
result: unknown | null;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
};
|
|
14
|
-
export type WorkerError = {
|
|
15
|
-
message: string | undefined;
|
|
16
|
-
logLines: string[];
|
|
17
|
-
errLines: string[];
|
|
13
|
+
log_lines: string[];
|
|
14
|
+
err_lines: string[];
|
|
18
15
|
};
|
package/src/code-tool.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
|
-
import { McpTool, Metadata, ToolCallResult, asTextContentResult } from './types';
|
|
3
|
+
import { McpTool, Metadata, ToolCallResult, asErrorResult, asTextContentResult } from './types';
|
|
4
4
|
import { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
5
5
|
import { readEnv } from './server';
|
|
6
|
-
import {
|
|
6
|
+
import { WorkerInput, WorkerOutput } from './code-tool-types';
|
|
7
7
|
/**
|
|
8
8
|
* A tool that runs code against a copy of the SDK.
|
|
9
9
|
*
|
|
@@ -44,9 +44,9 @@ export function codeTool(): McpTool {
|
|
|
44
44
|
},
|
|
45
45
|
body: JSON.stringify({
|
|
46
46
|
project_name: 'spotted',
|
|
47
|
-
client_opts: {},
|
|
48
47
|
code,
|
|
49
|
-
|
|
48
|
+
client_opts: {},
|
|
49
|
+
} satisfies WorkerInput),
|
|
50
50
|
});
|
|
51
51
|
|
|
52
52
|
if (!res.ok) {
|
|
@@ -57,7 +57,17 @@ export function codeTool(): McpTool {
|
|
|
57
57
|
);
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
const { is_error, result, log_lines, err_lines } = (await res.json()) as WorkerOutput;
|
|
61
|
+
const hasLogs = log_lines.length > 0 || err_lines.length > 0;
|
|
62
|
+
const output = {
|
|
63
|
+
result,
|
|
64
|
+
...(log_lines.length > 0 && { log_lines }),
|
|
65
|
+
...(err_lines.length > 0 && { err_lines }),
|
|
66
|
+
};
|
|
67
|
+
if (is_error) {
|
|
68
|
+
return asErrorResult(typeof result === 'string' && !hasLogs ? result : JSON.stringify(output, null, 2));
|
|
69
|
+
}
|
|
70
|
+
return asTextContentResult(output);
|
|
61
71
|
};
|
|
62
72
|
|
|
63
73
|
return { metadata, tool, handler };
|