-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Embedded MCP tools currently have static schemas defined in TOML files, but many tools could benefit from dynamically generated schemas based on external data sources. For example, a GitHub label management tool should have an enum of valid label names fetched from the GitHub API, ensuring the assistant only suggests valid options.
Context
When working with tools that interact with external systems, the available options or valid values often change dynamically. Currently, MCP tool schemas in .jp/mcp/tools/*.toml files have static properties definitions that cannot adapt to external data sources.
A common example is GitHub integration tools - a tool for adding labels to issues should present an enum of all available labels in the repository, but these labels are managed dynamically through GitHub's interface and can change over time.
Alternatives
Manual schema updates could work but would require constant maintenance as external data changes. Static schemas with string validation in the tool implementation could work but provide poor UX as the assistant wouldn't know valid options upfront.
Proposed Implementation
Add a preprocessor field to the MCP tool TOML configuration that points to an executable file. This executable would:
- Receive the current JSON schema via stdin
- Have access to workspace context and configuration
- Return the final processed schema via stdout
- Be executed when
jp querystarts and the tool is available
For caching, start with rebuilding schemas on each jp query command startup, with future TTL/caching optimizations as a follow-up enhancement.
Example TOML configuration:
[tool]
description = "Add labels to GitHub issues"
command = ["github_label_tool"]
preprocessor = "scripts/github_labels_preprocessor.sh"
[[tool.properties]]
name = "labels"
type = "array"
# This enum will be populated by the preprocessor
items = { type = "string" }The preprocessor script would fetch available labels via GitHub API and inject them into the schema enum.
Tasks
- Add
preprocessorfield toMcpToolstruct incrates/jp_mcp/src/tool.rs - Update tool loading logic in
crates/jp_storage/src/lib.rsto execute preprocessor if specified - Add schema preprocessing to embedded server tool enumeration in
crates/jp_mcp/src/server/embedded.rs - Add error handling for preprocessor execution failures
- Add documentation and examples for preprocessor usage