Skip to content

Add tool definitions annotation support to registry server - #414

Merged
rdimitrov merged 2 commits into
mainfrom
tool-definitions-support
Jan 28, 2026
Merged

Add tool definitions annotation support to registry server#414
rdimitrov merged 2 commits into
mainfrom
tool-definitions-support

Conversation

@lujunsan

@lujunsan lujunsan commented Jan 27, 2026

Copy link
Copy Markdown
Contributor

Adds support for the toolhive.stacklok.dev/tool-definitions annotation to the registry server, allowing MCP server publishers to declare custom tool definitions that are exposed through the registry API.

This implements the registry-server side of RFC-0015.

Changes

  • Added defaultRegistryToolDefinitionsAnnotation constant for the tool definitions annotation
  • Created shared extractToolDefinitions() helper function to parse and validate tool definitions
  • Updated all three resource extraction functions to support tool definitions:
    • extractServer() (MCPServer)
    • extractVirtualMCPServer() (VirtualMCPServer)
    • extractMCPRemoteProxy() (MCPRemoteProxy)
  • Tool definitions are parsed as JSON to validate syntax, but schema validation is not performed (operator's responsibility)
  • Parsed tool definitions are stored in _meta.publisher-provided.<url>.tool_definitions
  • Added comprehensive unit tests for all three resource types covering valid, invalid, empty, and multiple tool scenarios

Technical Details

The registry server reads the toolhive.stacklok.dev/tool-definitions annotation from Kubernetes MCP resources and:

  1. Validates the annotation contains valid JSON syntax
  2. Logs a warning and skips if JSON is invalid
  3. Stores the parsed structure in the server metadata for API exposure
  4. Maintains backward compatibility - resources without tool definitions continue to work

The implementation does NOT validate the tool definition schema itself, as that is the operator's responsibility during reconciliation.

Testing

  • Manual testing performed with test Kubernetes resources
  • Unit tests added following existing table-driven test patterns
  • Verified tool definitions appear correctly in API responses as JSON arrays
  • Tested backward compatibility with resources lacking tool definitions

Related

  • Implements RFC-0015 (registry-server side)

Signed-off-by: lujunsan <luisjuncaldev@gmail.com>
@lujunsan
lujunsan requested review from blkt and rdimitrov January 27, 2026 12:18
@codecov-commenter

codecov-commenter commented Jan 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.17%. Comparing base (5b09174) to head (8bc8904).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #414      +/-   ##
==========================================
+ Coverage   61.08%   61.17%   +0.09%     
==========================================
  Files          81       81              
  Lines        7426     7444      +18     
==========================================
+ Hits         4536     4554      +18     
  Misses       2582     2582              
  Partials      308      308              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lujunsan
lujunsan marked this pull request as ready for review January 27, 2026 14:44
@rdimitrov
rdimitrov merged commit 47af95a into main Jan 28, 2026
13 checks passed
@rdimitrov
rdimitrov deleted the tool-definitions-support branch January 28, 2026 00:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants