@usefillo/mcp 0.7.0 → 0.7.1
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/dist/index.js +21 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,24 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
// src/
|
|
3
|
+
// src/telemetry.ts
|
|
4
|
+
import { AsyncLocalStorage } from "async_hooks";
|
|
4
5
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
6
|
+
var toolContext = new AsyncLocalStorage();
|
|
7
|
+
function currentTool() {
|
|
8
|
+
return toolContext.getStore();
|
|
9
|
+
}
|
|
10
|
+
var ObservedMcpServer = class extends McpServer {
|
|
11
|
+
registerTool(name, config, cb) {
|
|
12
|
+
const wrapped = new Proxy(cb, {
|
|
13
|
+
apply(target, thisArg, args) {
|
|
14
|
+
return toolContext.run(name, () => Reflect.apply(target, thisArg, args));
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
return super.registerTool(name, config, wrapped);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
// src/index.ts
|
|
5
22
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
6
23
|
|
|
7
24
|
// src/config.ts
|
|
@@ -202,6 +219,8 @@ async function filloFetch(path, init = {}) {
|
|
|
202
219
|
const query = init.searchParams?.toString();
|
|
203
220
|
const url = `${apiOrigin()}${path}${query ? `?${query}` : ""}`;
|
|
204
221
|
const headers = { "X-Fillo-Client": CLIENT_VERSION };
|
|
222
|
+
const tool = currentTool();
|
|
223
|
+
if (tool) headers["X-Fillo-Tool"] = tool;
|
|
205
224
|
if (init.body !== void 0) headers["Content-Type"] = "application/json";
|
|
206
225
|
if (init.token) headers.Authorization = `Bearer ${init.token}`;
|
|
207
226
|
const res = await fetch(url, {
|
|
@@ -3273,7 +3292,7 @@ function registerTools(server) {
|
|
|
3273
3292
|
// src/index.ts
|
|
3274
3293
|
async function main() {
|
|
3275
3294
|
const version = CLIENT_VERSION.split("@").pop() ?? "0.0.0";
|
|
3276
|
-
const server = new
|
|
3295
|
+
const server = new ObservedMcpServer({ name: "fillo", version });
|
|
3277
3296
|
registerTools(server);
|
|
3278
3297
|
const transport = new StdioServerTransport();
|
|
3279
3298
|
await server.connect(transport);
|
package/package.json
CHANGED