Skip to content

Conversation

@jboolean
Copy link

@jboolean jboolean commented Nov 5, 2025

What does this PR do?

Adds contrib library for mcp-go. Uses it to record LLMObs Tool spans for tool calls.

This is the base of a Graphite stack.

image.png

Motivation

Tech spec for this project

Closes MLOB-4372

Reviewer's Checklist

  • Changed code has unit tests for its functionality at or near 100% coverage.
  • System-Tests covering this feature have been added and enabled with the va.b.c-dev version tag.
  • There is a benchmark for any new code, or changes to existing code.
  • If this interacts with the agent in a new way, a system test has been added.
  • New code is free of linting errors. You can check this by running ./scripts/lint.sh locally.
  • Add an appropriate team label so this PR gets put in the right place for the release notes.
  • Non-trivial go.mod changes, e.g. adding new modules, are reviewed by @DataDog/dd-trace-go-guild.

Testing

In addition to automated tests, this was tested locally with Datadog MCP Server

Unsure? Have a question? Request a review!

Copy link
Author

jboolean commented Nov 5, 2025

@github-actions github-actions bot added the apm:ecosystem contrib/* related feature requests or bugs label Nov 5, 2025
@pr-commenter
Copy link

pr-commenter bot commented Nov 5, 2025

Benchmarks

Benchmark execution time: 2025-11-05 20:59:25

Comparing candidate commit b00ba8a in PR branch jb/contrib-mcp-go-base with baseline commit 53b84e7 in branch main.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 24 metrics, 0 unstable metrics.

@jboolean jboolean changed the title Initial mcp-go tracer implementation Initial mcp-go tracer implementation Nov 5, 2025
@datadog-official
Copy link
Contributor

datadog-official bot commented Nov 5, 2025

✅ Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: b00ba8a | Docs | Datadog PR Page | Was this helpful? Give us feedback!

// Hooks provides Datadog tracing for MCP servers.
type Hooks struct {
// Stores data between start and end of tool calls. In-memory works because it must be on the same instance.
toolCache *ttlcache.Cache[any, *llmobs.ToolSpan]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The in-memory cache just stores data between the start and end hooks. Creating a middleware would have avoided this, but would have been harder to automatically add to all tools. We'll also use hooks for session initialization spans (another PR on this stack).

Unfortunately this cache implementation does need to be shut down manually.

I experimented with but decided against cache customization options (max size, ttl).

@jboolean jboolean changed the title Initial mcp-go tracer implementation feat(contrib/mcp-go): Initial mcp-go tracer implementation Nov 5, 2025
@jboolean jboolean requested a review from a team November 5, 2025 21:15
@jboolean jboolean requested a review from tomshen November 5, 2025 21:16
@jboolean jboolean requested a review from rarguelloF November 5, 2025 21:16
@jboolean jboolean marked this pull request as ready for review November 5, 2025 21:18
@jboolean jboolean requested review from a team as code owners November 5, 2025 21:18
@tomshen tomshen removed their assignment Nov 6, 2025
@tomshen tomshen removed their request for review November 6, 2025 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

apm:ecosystem contrib/* related feature requests or bugs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants