An MCP server for dynamic tool registration and AI-powered simulation via Goose recipes
Project description
mcp-on-demand-tools
A Model Context Protocol (MCP) server that enables dynamic tool registration and execution powered by AI agents. Register custom tools on-the-fly and have them simulated by Goose recipe-based agents.
Overview
This MCP server allows you to dynamically register new tools at runtime without server restarts. When you invoke a registered tool, the server uses a Goose recipe (render_template.yaml) to simulate the tool's execution and generate realistic output based on the tool's contract. This is useful for prototyping tool capabilities, testing workflows, or creating mock implementations before building real integrations.
Components
Resources
The server provides resources for monitoring registered tools:
-
Tool definition resources (
tool://internal/{tool-name})- Returns the complete tool schema including name, description, parameters, expected output, and side effects
- Includes call count statistics for monitoring usage
-
Stats resource (
stats://internal/summary)- Shows aggregate statistics: total tools registered, total calls made
- Lists top 10 tools by call count
Prompts
- plan-with-tools: A planning prompt that helps orchestrate tool usage
- Arguments:
goal(required),notes(optional) - Lists all currently registered tools and suggests registering new ones if needed
- Arguments:
Tools
Core Tool
- register-tool: Dynamically register a new on-demand tool
- Required parameters:
name: Tool identifier (string)description: What the tool does (string)paramSchema: JSON object defining tool parameters. Each parameter should havedescriptionandtypeproperties. Can be provided as an object or JSON string.expectedOutput: Description of what the tool returns (string)sideEffects: Description of any side effects, e.g., "Makes API call to weather service" or "None - simulated data generation" (string)
- Required parameters:
Dynamic Tools
Once registered, tools become immediately available for invocation. Each registered tool:
- Accepts a
paramsargument (object or JSON string) - Executes via a Goose recipe (
render_template.yaml) which uses an AI model to generate realistic output - Returns simulated output matching the expected output contract
- The server automatically notifies connected MCP clients when new tools are registered or when tool usage statistics change
How It Works
- Register a tool using the
register-toolMCP tool with your desired schema - Tool becomes available immediately - the server sends notifications to connected clients
- Invoke the tool with specific parameter values
- Goose recipe executes to simulate the tool and generate realistic output based on the contract
- View statistics via resources to monitor tool usage and call history
Architecture
┌─────────────────┐
│ MCP Client │
│ (Goose, etc) │
└────────┬────────┘
│
│ register-tool
▼
┌─────────────────────────┐
│ MCP Server │
│ (mcp-on-demand-tools) │
│ │
│ • Stores tool metadata │
│ • Tracks call history │
│ • Provides resources │
└────────┬────────────────┘
│
│ invoke: tool-name(params)
▼
┌─────────────────────────┐
│ Goose Recipe Runner │
│ (render_template.yaml) │
│ │
│ Simulates tool based │
│ on contract & params │
└─────────────────────────┘
Example Workflow
// Step 1: Register a weather forecast tool
{
"name": "get-weather-forecast",
"description": "Fetches weather forecast for a given location",
"paramSchema": {
"location": {
"description": "City name or coordinates",
"type": "string"
},
"days": {
"description": "Number of days to forecast (1-7)",
"type": "integer"
}
},
"expectedOutput": "Weather forecast data including temperature, conditions, and precipitation",
"sideEffects": "None - simulated data generation"
}
// Step 2: Tool is now available in MCP
// Step 3: Invoke it
{
"params": {
"location": "San Francisco",
"days": 3
}
}
// Step 4: Goose generates realistic weather data matching the contract
Installation
Prerequisites
Required:
- Python 3.12 or higher
- Goose - Must be installed and available in your PATH
uvpackage manager (recommended) orpip
Important: This server requires Goose to function. It uses Goose recipes to simulate tool execution, so you must have Goose installed before using this MCP server.
Compatibility Note: This server works best with MCP clients that support dynamic tool list updates (like Goose Desktop). Claude Code client does not automatically refresh the tool list when new tools are registered, so it may not work well with that client.
Installing the MCP Server
Add the server configuration to your config file:
Option 1: Use Published Package (Recommended)
{
"mcpServers": {
"mcp-on-demand-tools": {
"command": "uvx",
"args": ["mcp-on-demand-tools"]
}
}
}
Option 2: Development Setup
Clone the repository and use local installation:
{
"mcpServers": {
"mcp-on-demand-tools": {
"command": "uv",
"args": [
"--directory",
"/absolute/path/to/mcp-on-demand-tools",
"run",
"mcp-on-demand-tools"
]
}
}
}
Installing for Other MCP Clients
For other MCP-compatible clients, configure them to run:
uvx mcp-on-demand-tools
Or for development:
uv --directory /path/to/mcp-on-demand-tools run mcp-on-demand-tools
Development
Setup
- Clone the repository:
git clone https://github.com/yourusername/mcp-on-demand-tools.git
cd mcp-on-demand-tools
- Install dependencies:
uv sync
- Run locally:
uv run mcp-on-demand-tools
Building and Publishing
To prepare the package for distribution:
- Build package distributions:
uv build
This creates source and wheel distributions in the dist/ directory.
- Publish to PyPI:
uv publish
Note: Publishing requires PyPI credentials via environment variables or command flags:
- Token:
--tokenorUV_PUBLISH_TOKEN - Or username/password:
--username/UV_PUBLISH_USERNAMEand--password/UV_PUBLISH_PASSWORD
Automated Publishing
The project includes a GitHub Actions workflow that automatically:
- Builds the package on every push
- Publishes to TestPyPI on pushes to
mainbranch - Publishes to PyPI when you create a git tag (e.g.,
v0.1.0)
To publish a new version:
git tag v0.1.1
git push origin v0.1.1
Debugging
Since MCP servers run over stdio, debugging can be challenging. For the best debugging experience, use the MCP Inspector:
npx @modelcontextprotocol/inspector uv --directory /path/to/mcp-on-demand-tools run mcp-on-demand-tools
Upon launching, the Inspector will display a URL that you can access in your browser to begin debugging.
Project Structure
mcp-on-demand-tools/
├── src/
│ └── mcp_on_demand_tools/
│ ├── __init__.py # Package entry point
│ ├── server.py # Main MCP server implementation
│ └── recipes/
│ └── render_template.yaml # Goose recipe for tool simulation
├── pyproject.toml # Project metadata and dependencies
├── uv.lock # Locked dependencies
└── README.md # This file
How Tool Execution Works
When you invoke a registered tool:
- The MCP server receives the tool call with parameters
- It constructs a context string with:
- Tool name and description
- Expected output contract
- Side effects declaration
- Input parameters (as JSON)
- Aggregate context: History of previous calls to this tool (if any)
- The server executes
goose run --recipe render_template.yamlwith these parameters - Goose's AI agent reads the contract and generates realistic output that matches the expected format
- The output is extracted and returned to the MCP client
Stateful Tool Execution
New in v0.1.2: The server now maintains call history for each registered tool. When you invoke a tool multiple times, the AI agent receives context from previous calls, enabling:
- Conversational tools: Tools can maintain context across multiple invocations
- Incremental workflows: Each call can build upon previous results
- State-aware responses: The AI can generate outputs that reference or continue from previous interactions
The aggregate context includes:
- Total number of previous calls
- Input parameters from each previous call
- Exit codes and outputs (first 200 characters)
- Call sequence/order
This allows the tool simulator to provide more coherent and contextual responses in multi-turn interactions.
Use Cases
This server is ideal for:
- Rapid prototyping: Test tool concepts without implementing full functionality
- API design exploration: Experiment with tool interfaces before committing to implementation
- Workflow testing: Validate complex workflows with realistic mock data
- Demonstration and documentation: Show how tools would work without building them
- Placeholder tools: Create temporary tool implementations during development
Changelog
v0.1.1 (2025-10-12)
- Added aggregate context support: Tool executions now receive history from previous calls
- Enables stateful, conversational tool behavior across multiple invocations
- AI agent can now generate contextually-aware responses based on call history
v0.1.0
- Initial release
- Initial MCP server implementation
- Dynamic tool registration
- Goose recipe-based tool simulation
License
See LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mcp_on_demand_tools-0.1.1.tar.gz.
File metadata
- Download URL: mcp_on_demand_tools-0.1.1.tar.gz
- Upload date:
- Size: 33.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
549b47930e95535ae5349b14f2e14550fecb1903d2e361918f81e89b32a3097c
|
|
| MD5 |
0e646c5b29aacdcde18d651edafb6e1f
|
|
| BLAKE2b-256 |
75656621c5893c41d88e970d875621aa209035ec6500987e97619ae7c0f765e3
|
File details
Details for the file mcp_on_demand_tools-0.1.1-py3-none-any.whl.
File metadata
- Download URL: mcp_on_demand_tools-0.1.1-py3-none-any.whl
- Upload date:
- Size: 14.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0a1939084d11576078e277536770018563adcca741218489d43464c38a9b68b7
|
|
| MD5 |
5734d9205ecf1c6f5822410e91d73bf8
|
|
| BLAKE2b-256 |
29fa1f07c647c71d0709b0924fb060f876802fa9167bcdd8ab673caba2718b86
|