Effect CommunityEC
Effect Community6mo ago
5 replies
vivi

Can't use tracing with @effect/ai McpServer

I can create and run AiTools with handlers that have spans/logs/metrics, and everything works fine when I manually run the tool with:

(yield* toolkit).handle(name, parameters)


The logs, metrics, and traces all go to the grafana dashboard just fine. But when I expose the AiTool via an McpServer, I get this error:

 ResponseError: StatusCode: non 2xx status code (400 POST http://host.docker.internal:4318/v1/traces) at self (/workspace/node_modules/.pnpm/@effect+platform@0.87.10_effect@3.16.12/node_modules/@effect/platform/src/internal/


After a little digging I found this:

[HTTP ERROR] Response body: {"code":3,"message":"readLog.traceId: parse trace_id:invalid length for ID, error found in #10 byte of ...|Id\":\"noop\",\"spanId\":|..., bigger context ...|rted\"},\"droppedAttributesCount\":0,\"traceId\":\"noop\",\"spanId\":\"d265e855937b3a73\"},{\"severityNumber\":1,|..."}


It looks like the McpServer is getting rid of the traceId or something so it gets replaced with noop by the Rpc layer which gets rejected by Grafana, or something like that. How can I get observability working for AI tools running through a MCP server?
Was this page helpful?