@talqing/mcp 0.1.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.
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Talqing MCP server.
4
+ *
5
+ * Serves the platform's agent-building operations to any MCP client and
6
+ * executes each call against the Talqing API with a personal access token. The
7
+ * tool list is `tools.json` and the instructions are `SKILL.md` — both generated
8
+ * from the same source as our own CoPilot's tools and prompt, so an agent
9
+ * driving Talqing from here can do exactly what the in-product CoPilot can.
10
+ *
11
+ * A token acts as its creator, with that user's live role, inside their
12
+ * workspace only. Nothing here can widen that.
13
+ */
14
+ export {};
package/dist/index.js ADDED
@@ -0,0 +1,117 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Talqing MCP server.
4
+ *
5
+ * Serves the platform's agent-building operations to any MCP client and
6
+ * executes each call against the Talqing API with a personal access token. The
7
+ * tool list is `tools.json` and the instructions are `SKILL.md` — both generated
8
+ * from the same source as our own CoPilot's tools and prompt, so an agent
9
+ * driving Talqing from here can do exactly what the in-product CoPilot can.
10
+ *
11
+ * A token acts as its creator, with that user's live role, inside their
12
+ * workspace only. Nothing here can widen that.
13
+ */
14
+ import { readFileSync } from "node:fs";
15
+ import { dirname, join } from "node:path";
16
+ import { fileURLToPath } from "node:url";
17
+ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
18
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
19
+ import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
20
+ const PACKAGE_ROOT = join(dirname(fileURLToPath(import.meta.url)), "..");
21
+ function readPackageFile(name) {
22
+ return readFileSync(join(PACKAGE_ROOT, name), "utf8");
23
+ }
24
+ /** Required environment. Missing configuration fails at startup, not mid-call. */
25
+ function required(name, hint) {
26
+ const value = process.env[name]?.trim();
27
+ if (!value)
28
+ throw new Error(`${name} is not set — ${hint}`);
29
+ return value;
30
+ }
31
+ const BASE_URL = required("TALQING_BASE_URL", "set it to your Talqing API URL, e.g. https://api.your-talqing-host.com").replace(/\/+$/, "");
32
+ const API_KEY = required("TALQING_API_KEY", "create a personal access token in the dashboard under Settings → Tokens");
33
+ const { tools: operations } = JSON.parse(readPackageFile("tools.json"));
34
+ const byName = new Map(operations.map((operation) => [operation.name, operation]));
35
+ /** The skill, minus its frontmatter — handed to the client as server instructions. */
36
+ function instructions() {
37
+ const markdown = readPackageFile("SKILL.md");
38
+ const end = markdown.indexOf("\n---", 3);
39
+ return (markdown.startsWith("---") && end !== -1 ? markdown.slice(end + 4) : markdown).trim();
40
+ }
41
+ function describe(operation) {
42
+ return {
43
+ name: operation.name,
44
+ description: `${operation.method} ${operation.path}\n\n${operation.description}`,
45
+ inputSchema: operation.parameters,
46
+ annotations: {
47
+ readOnlyHint: operation.read_only,
48
+ destructiveHint: operation.method === "DELETE",
49
+ idempotentHint: ["GET", "PUT", "DELETE"].includes(operation.method),
50
+ openWorldHint: false,
51
+ },
52
+ };
53
+ }
54
+ /**
55
+ * Turn tool arguments into the HTTP request they stand for: `{name}`
56
+ * placeholders in the path are path parameters, `body` is the JSON body, and
57
+ * everything else left over is a query parameter.
58
+ */
59
+ function requestFor(operation, args) {
60
+ const remaining = { ...args };
61
+ const path = operation.path.replace(/\{([^}]+)\}/g, (_match, name) => {
62
+ const value = remaining[name];
63
+ if (value === undefined || value === null)
64
+ throw new Error(`${name} is required`);
65
+ delete remaining[name];
66
+ return encodeURIComponent(String(value));
67
+ });
68
+ const body = remaining.body;
69
+ delete remaining.body;
70
+ const url = new URL(BASE_URL + path);
71
+ for (const [key, value] of Object.entries(remaining)) {
72
+ if (value !== undefined && value !== null)
73
+ url.searchParams.set(key, String(value));
74
+ }
75
+ const headers = { authorization: `Bearer ${API_KEY}` };
76
+ if (body !== undefined)
77
+ headers["content-type"] = "application/json";
78
+ return new Request(url, {
79
+ method: operation.method,
80
+ headers,
81
+ body: body === undefined ? undefined : JSON.stringify(body),
82
+ });
83
+ }
84
+ function failure(message, errors = []) {
85
+ return {
86
+ content: [{ type: "text", text: JSON.stringify({ detail: { message, errors } }) }],
87
+ isError: true,
88
+ };
89
+ }
90
+ async function call(name, args) {
91
+ const operation = byName.get(name);
92
+ if (!operation)
93
+ return failure(`unknown operation: ${name}`);
94
+ let response;
95
+ try {
96
+ response = await fetch(requestFor(operation, args));
97
+ }
98
+ catch (error) {
99
+ // A bad argument (missing path parameter) and an unreachable API both land
100
+ // here; either way the model gets a readable error in the API's own shape.
101
+ return failure(error instanceof Error ? error.message : String(error));
102
+ }
103
+ const text = await response.text();
104
+ if (!response.ok) {
105
+ // Errors already carry {detail: {message, errors}} — pass them through so
106
+ // one error shape reaches the model whichever operation failed.
107
+ return { content: [{ type: "text", text: text || response.statusText }], isError: true };
108
+ }
109
+ return { content: [{ type: "text", text: text || "{}" }] };
110
+ }
111
+ const server = new Server({ name: "talqing", version: "0.1.0" }, { capabilities: { tools: {} }, instructions: instructions() });
112
+ server.setRequestHandler(ListToolsRequestSchema, async () => ({
113
+ tools: operations.map(describe),
114
+ }));
115
+ server.setRequestHandler(CallToolRequestSchema, async (request) => call(request.params.name, (request.params.arguments ?? {})));
116
+ await server.connect(new StdioServerTransport());
117
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GAGvB,MAAM,oCAAoC,CAAC;AA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AC,MAAM,CAAC,SAAS,IAAI,EAAE,CAA4B,CAAC,CACvF,CAAC;AAEF,MAAM,MAAM,CAAC,OAAO,CAAC,IAAI,oBAAoB,EAAE,CAAC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@talqing/mcp",
3
+ "version": "0.1.0",
4
+ "description": "MCP server for building Talqing AI voice, video and text agents from Claude Code, Codex, or any MCP client.",
5
+ "license": "MIT",
6
+ "homepage": "https://talqing.com",
7
+ "bugs": {
8
+ "email": "hello@talqing.com"
9
+ },
10
+ "keywords": [
11
+ "talqing",
12
+ "mcp",
13
+ "model-context-protocol",
14
+ "ai",
15
+ "agents",
16
+ "voice"
17
+ ],
18
+ "type": "module",
19
+ "bin": {
20
+ "talqing-mcp": "./dist/index.js"
21
+ },
22
+ "files": [
23
+ "dist",
24
+ "tools.json",
25
+ "SKILL.md",
26
+ "README.md"
27
+ ],
28
+ "engines": {
29
+ "node": ">=20"
30
+ },
31
+ "publishConfig": {
32
+ "access": "public"
33
+ },
34
+ "scripts": {
35
+ "build": "tsc -p tsconfig.json",
36
+ "typecheck": "tsc --noEmit -p tsconfig.json",
37
+ "start": "node dist/index.js",
38
+ "prepublishOnly": "npm run build"
39
+ },
40
+ "dependencies": {
41
+ "@modelcontextprotocol/sdk": "^1.30.0"
42
+ },
43
+ "devDependencies": {
44
+ "@types/node": "^22.10.0",
45
+ "typescript": "^5.9.3"
46
+ }
47
+ }