feat: add MCP server, McpChannel, eval primitives, and OTel tracing#35
Merged
sajeerzeji merged 5 commits intoJun 7, 2026
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat(toolpack-sdk, toolpack-agents): MCP server, eval primitives, OTel tracing, and McpChannel
Summary
This PR ships four major capabilities across
toolpack-sdkandtoolpack-agents:toolpack-sdk) — expose Toolpack as an MCP server over HTTP or stdiotoolpack-agents) — dataset management, test runner, scoring, and regression reportstoolpack-agents) — OpenTelemetry interceptor for distributed tracestoolpack-agents) — bridge Toolpack agents into an MCP server as callable tools1. MCP Server (
sdk.startMcpServer())Toolpack can now act as a fully spec-compliant MCP server (Streamable HTTP transport), exposing its 100+ built-in tools to any MCP client — Claude Desktop, Cursor, or custom agents.
Key features:
port: 0support — OS-assigned free port; actual port returned onMcpServerHandle.portexpose: { categories }orexpose: { tools }to restrict what's visiblestatic(pre-shared tokens),jwt(JWKS/Auth0/Supabase/Clerk),custom(bring your own verifier)searchMode: trueexposes onlytool.search; clients discover tools on demand, drastically reducing context token usage for large tool registriesMcpAgentDefinitionappear asagent.<name>intools/list/.well-known/oauth-protected-resourcemounted automatically in JWT modeNew files:
packages/toolpack-sdk/src/mcp/server.ts— core server implementationpackages/toolpack-sdk/src/mcp/server-types.ts—McpServerHandle,McpAgentDefinition, all auth config typespackages/toolpack-sdk/src/mcp/server-auth.ts— static / JWT / custom auth middlewarepackages/toolpack-sdk/docs/examples/mcp-server-example.ts— full working exampleModified:
packages/toolpack-sdk/src/toolpack.ts—Toolpack.startMcpServer()public API addedpackages/toolpack-sdk/src/mcp/index.ts— new exports wired uppackages/toolpack-sdk/src/tools/registry.ts—k8sToolsProjectadded toloadBuiltIn()(fixed tool count: 95 → 106)Tests:
packages/toolpack-sdk/tests/integration/mcp-server.test.ts— 15 HTTP integration tests (real server, no mocking); opt-in viaRUN_INTEGRATION_TESTS=1packages/toolpack-sdk/tests/unit/mcp-server.test.ts— unit testspackages/toolpack-sdk/tests/unit/mcp-server-auth.test.ts— auth unit tests2. Eval Primitives (
@toolpack-sdk/agents)A lightweight eval framework for tracking agent answer quality over time.
New files:
eval-types.ts—EvalCase,EvalRun,EvalVerdict,EvalReporttypeseval-dataset.ts—EvalDataset: holds cases, supports filter/addeval-runner.ts—EvalRunner: runs each case through an agent, collects resultseval-scorer.ts—ExactMatchScorer,ContainsScorer,LLMJudgeScorer,CustomScorereval-report.ts—compareEvalRuns(),formatEvalReport()for regression detectionUsage pattern:
All primitives exported from
@toolpack-sdk/agentsmain entry point.3. OTel Tracing (
createOTelTracerInterceptor)An OpenTelemetry interceptor that creates a span per agent invocation, compatible with any OTel-compliant backend (Jaeger, Honeycomb, Datadog, etc.).
New file:
packages/toolpack-agents/src/interceptors/builtins/otel-tracer.tsExported as
createOTelTracerInterceptorfrom@toolpack-sdk/agents.4. McpChannel
Bridges a Toolpack agent into an MCP server. When an MCP client calls
tools/callforagent.<name>,McpChanneldelivers the input to the agent'sinvokeAgent()and returns the output as the MCP tool result.New files:
packages/toolpack-agents/src/channels/mcp-channel.tspackages/toolpack-agents/src/channels/mcp-channel.test.tsUsage:
Exported from
@toolpack-sdk/agentsasMcpChannelandMcpChannelConfig.Bug fixes
k8sToolsProjectmissing fromloadBuiltIn()— Kubernetes tools existed in the codebase but were never registered. Fixed; tool count goes 95 → 106.test-mcp-server.tsandtest-mcp-server-http.tsfrom repo root deleted; replaced by proper integration tests.Documentation
All affected documentation updated:
README.md(root + packages)documentation/docs/guides/mcp-server.mddocumentation/docs/agents/channels.mddocumentation/docs/agents/testing.mdpackages/toolpack-agents/README.mdpackages/toolpack-agents/docs/channels.mdpackages/toolpack-agents/docs/testing.mdpackages/toolpack-agents/package.jsondocumentation/docusaurus.config.tsdocumentation/docs/intro.mddocumentation/docs/tools/overview.mddevelopment/docs-staged/README.mdTest plan
npm run testpasses intoolpack-sdkandtoolpack-agentsRUN_INTEGRATION_TESTS=1 npx vitest run tests/integration/mcp-server.test.ts— all 15 tests passsearchMode: true—tools/listreturns onlytool.searchMcpChannelis callable from an MCP client asagent.<name>compareEvalRunsreturns emptyregressionsarray on identical runs