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.
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.
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
- 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:
- 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:
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
- 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
┌─────────────────┐
│ 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 │
└─────────────────────────┘
// 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 contractRequired:
- 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.
Add the server configuration to your config file:
{
"mcpServers": {
"mcp-on-demand-tools": {
"command": "uvx",
"args": ["mcp-on-demand-tools"]
}
}
}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"
]
}
}
}For other MCP-compatible clients, configure them to run:
uvx mcp-on-demand-toolsOr for development:
uv --directory /path/to/mcp-on-demand-tools run mcp-on-demand-tools- 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-toolsTo prepare the package for distribution:
- Build package distributions:
uv buildThis creates source and wheel distributions in the dist/ directory.
- Publish to PyPI:
uv publishNote: 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
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.1Since 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-toolsUpon launching, the Inspector will display a URL that you can access in your browser to begin debugging.
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
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
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.
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
- 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
- Initial release
- Initial MCP server implementation
- Dynamic tool registration
- Goose recipe-based tool simulation
See LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.