@talqing/mcp 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/SKILL.md +15 -5
- package/dist/index.d.ts +1 -1
- package/dist/index.js +20 -20
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/tools.json +497 -4434
package/SKILL.md
CHANGED
|
@@ -624,7 +624,11 @@ instead.
|
|
|
624
624
|
`export default async function handler(input)`, where `input` is
|
|
625
625
|
`{args, tooldata, userdata, system_vars, vars, secrets}`, and return an object.
|
|
626
626
|
The sandbox has `console` and a guarded `fetch` for public http(s) URLs — no
|
|
627
|
-
Node APIs, no imports.
|
|
627
|
+
Node APIs, no imports. **That `fetch` is not how you call an API.** A plain
|
|
628
|
+
request/response call is an `http` operation: it costs no isolate, and the
|
|
629
|
+
person who owns this tool can read and edit it in the editor rather than
|
|
630
|
+
reading your TypeScript. Reach for `fetch` only for what `http` cannot say —
|
|
631
|
+
a second call that depends on the first, or a non-JSON response.
|
|
628
632
|
|
|
629
633
|
That input object is the whole interface: a code operation has **no template
|
|
630
634
|
syntax**. Write `input.system_vars.now`, never `{{system_vars.now}}` — braces
|
|
@@ -1258,11 +1262,17 @@ and the final `userdata` usually name the cause.
|
|
|
1258
1262
|
against rules you cannot check by reading a draft, so **never report a
|
|
1259
1263
|
validation result you did not get back from the operation**, and never answer
|
|
1260
1264
|
a request to validate by reasoning about the config instead of calling it.
|
|
1265
|
+
- **Fetch the shape before you call.** Your tools carry a name and a description
|
|
1266
|
+
but not their arguments: `describe_function('name')` returns the argument
|
|
1267
|
+
schema, and you call it before the first time you use a function. Ask for
|
|
1268
|
+
everything a step needs in one go — these can be called side by side — and
|
|
1269
|
+
once you have a shape it stays good for the rest of the conversation. Two
|
|
1270
|
+
functions carry their own shape because they would otherwise be uncallable:
|
|
1271
|
+
`describe_function` itself, and `describe_schema`.
|
|
1261
1272
|
- **Do not invent fields.** Author tools and configs through the exact schemas
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
reconstruct it from memory.
|
|
1273
|
+
you fetched. A field the schema does not have is rejected, and an argument
|
|
1274
|
+
whose description ends in `describe_schema('X')` carries a placeholder instead
|
|
1275
|
+
of its type — fetch that too, never reconstruct it from memory.
|
|
1266
1276
|
- **Say what the platform does not do.** Decline capabilities that do not exist
|
|
1267
1277
|
yet rather than approximating them.
|
|
1268
1278
|
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Talqing MCP server.
|
|
4
4
|
*
|
|
5
|
-
* Serves the platform's agent-building
|
|
5
|
+
* Serves the platform's agent-building functions to any MCP client and
|
|
6
6
|
* executes each call against the Talqing API with a personal access token. The
|
|
7
7
|
* tool list is `tools.json` and the instructions are `SKILL.md` — both generated
|
|
8
8
|
* from the same source as our own CoPilot's tools and prompt, so an agent
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Talqing MCP server.
|
|
4
4
|
*
|
|
5
|
-
* Serves the platform's agent-building
|
|
5
|
+
* Serves the platform's agent-building functions to any MCP client and
|
|
6
6
|
* executes each call against the Talqing API with a personal access token. The
|
|
7
7
|
* tool list is `tools.json` and the instructions are `SKILL.md` — both generated
|
|
8
8
|
* from the same source as our own CoPilot's tools and prompt, so an agent
|
|
@@ -28,10 +28,10 @@ function required(name, hint) {
|
|
|
28
28
|
throw new Error(`${name} is not set — ${hint}`);
|
|
29
29
|
return value;
|
|
30
30
|
}
|
|
31
|
-
const BASE_URL = required("TALQING_BASE_URL", "set it to your Talqing API URL, e.g. https://api.
|
|
31
|
+
const BASE_URL = required("TALQING_BASE_URL", "set it to your region's Talqing API URL, e.g. https://api.in.talqing.com").replace(/\/+$/, "");
|
|
32
32
|
const API_KEY = required("TALQING_API_KEY", "create a personal access token in the dashboard under Organization → API Tokens");
|
|
33
|
-
const { tools:
|
|
34
|
-
const byName = new Map(
|
|
33
|
+
const { tools: functions } = JSON.parse(readPackageFile("tools.json"));
|
|
34
|
+
const byName = new Map(functions.map((fn) => [fn.name, fn]));
|
|
35
35
|
/* Read, not restated. A client shows this version when it reports the server it
|
|
36
36
|
connected to, and a second copy of the number is one `npm version` away from
|
|
37
37
|
being wrong. */
|
|
@@ -42,15 +42,15 @@ function instructions() {
|
|
|
42
42
|
const end = markdown.indexOf("\n---", 3);
|
|
43
43
|
return (markdown.startsWith("---") && end !== -1 ? markdown.slice(end + 4) : markdown).trim();
|
|
44
44
|
}
|
|
45
|
-
function describe(
|
|
45
|
+
function describe(fn) {
|
|
46
46
|
return {
|
|
47
|
-
name:
|
|
48
|
-
description: `${
|
|
49
|
-
inputSchema:
|
|
47
|
+
name: fn.name,
|
|
48
|
+
description: `${fn.method} ${fn.path}\n\n${fn.description}`,
|
|
49
|
+
inputSchema: fn.parameters,
|
|
50
50
|
annotations: {
|
|
51
|
-
readOnlyHint:
|
|
52
|
-
destructiveHint:
|
|
53
|
-
idempotentHint: ["GET", "PUT", "DELETE"].includes(
|
|
51
|
+
readOnlyHint: fn.read_only,
|
|
52
|
+
destructiveHint: fn.method === "DELETE",
|
|
53
|
+
idempotentHint: ["GET", "PUT", "DELETE"].includes(fn.method),
|
|
54
54
|
openWorldHint: false,
|
|
55
55
|
},
|
|
56
56
|
};
|
|
@@ -60,9 +60,9 @@ function describe(operation) {
|
|
|
60
60
|
* placeholders in the path are path parameters, `body` is the JSON body, and
|
|
61
61
|
* everything else left over is a query parameter.
|
|
62
62
|
*/
|
|
63
|
-
function requestFor(
|
|
63
|
+
function requestFor(fn, args) {
|
|
64
64
|
const remaining = { ...args };
|
|
65
|
-
const path =
|
|
65
|
+
const path = fn.path.replace(/\{([^}]+)\}/g, (_match, name) => {
|
|
66
66
|
const value = remaining[name];
|
|
67
67
|
if (value === undefined || value === null)
|
|
68
68
|
throw new Error(`${name} is required`);
|
|
@@ -80,7 +80,7 @@ function requestFor(operation, args) {
|
|
|
80
80
|
if (body !== undefined)
|
|
81
81
|
headers["content-type"] = "application/json";
|
|
82
82
|
return new Request(url, {
|
|
83
|
-
method:
|
|
83
|
+
method: fn.method,
|
|
84
84
|
headers,
|
|
85
85
|
body: body === undefined ? undefined : JSON.stringify(body),
|
|
86
86
|
});
|
|
@@ -92,12 +92,12 @@ function failure(message, errors = []) {
|
|
|
92
92
|
};
|
|
93
93
|
}
|
|
94
94
|
async function call(name, args) {
|
|
95
|
-
const
|
|
96
|
-
if (!
|
|
97
|
-
return failure(`unknown
|
|
95
|
+
const fn = byName.get(name);
|
|
96
|
+
if (!fn)
|
|
97
|
+
return failure(`unknown function: ${name}`);
|
|
98
98
|
let response;
|
|
99
99
|
try {
|
|
100
|
-
response = await fetch(requestFor(
|
|
100
|
+
response = await fetch(requestFor(fn, args));
|
|
101
101
|
}
|
|
102
102
|
catch (error) {
|
|
103
103
|
// A bad argument (missing path parameter) and an unreachable API both land
|
|
@@ -107,14 +107,14 @@ async function call(name, args) {
|
|
|
107
107
|
const text = await response.text();
|
|
108
108
|
if (!response.ok) {
|
|
109
109
|
// Errors already carry {detail: {message, errors}} — pass them through so
|
|
110
|
-
// one error shape reaches the model whichever
|
|
110
|
+
// one error shape reaches the model whichever function failed.
|
|
111
111
|
return { content: [{ type: "text", text: text || response.statusText }], isError: true };
|
|
112
112
|
}
|
|
113
113
|
return { content: [{ type: "text", text: text || "{}" }] };
|
|
114
114
|
}
|
|
115
115
|
const server = new Server({ name: "talqing", version: VERSION }, { capabilities: { tools: {} }, instructions: instructions() });
|
|
116
116
|
server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
117
|
-
tools:
|
|
117
|
+
tools: functions.map(describe),
|
|
118
118
|
}));
|
|
119
119
|
server.setRequestHandler(CallToolRequestSchema, async (request) => call(request.params.name, (request.params.arguments ?? {})));
|
|
120
120
|
await server.connect(new StdioServerTransport());
|
package/dist/index.js.map
CHANGED
|
@@ -1 +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;AAc5C,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;AAEzE,SAAS,eAAe,CAAC,IAAY;IACnC,OAAO,YAAY,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,CAAC;AACxD,CAAC;AAED,kFAAkF;AAClF,SAAS,QAAQ,CAAC,IAAY,EAAE,IAAY;IAC1C,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC;IACxC,IAAI,CAAC,KAAK;QAAE,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,iBAAiB,IAAI,EAAE,CAAC,CAAC;IAC5D,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,QAAQ,GAAG,QAAQ,CACvB,kBAAkB,EAClB,
|
|
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;AA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