About mcp_prompt_mapper
mcp_prompt_mapper is a Python library that turns analyzer input into structured prompts for building MCP server resources, tools, and prompts. It supports Claude, Grok, and OpenAI APIs, with JSON or YAML output.
Key features
- 01Templates for resources and tools
- 02JSON and YAML output
- 03Claude, Grok, and OpenAI compatibility
- 04Schema-aware prompt completion
- 05Streaming input parsing
Use cases
- 01Generating MCP resource and tool prompts from analyzer data
- 02Producing schema-aware prompts in JSON or YAML
- 03Parsing streaming input for Claude Desktop
MCP support
The library generates prompts for creating MCP server resources, tools, and prompts; it does not itself expose an MCP server.
Configuration
Local server config is the same for every client. Copy it into your client’s MCP config file.
We haven’t collected a package or remote endpoint for this server. Follow the instructions in the project README.
Tools
Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.
Details
From the project READMEmcp_prompt_mapper
Introduction
mcp_prompt_mapper is an open-source library designed to generate optimal prompts tailored for Claude, Grok, and OpenAI APIs. It transforms input from mcp_input_analyzer into structured, efficient prompts that can be used to build various parts of the MCP server, including resources, tools, and additional prompts.
Features
- Prompt Templating: Generate custom templates for creating resources and tools.
- Custom Output Formats: Supports both YAML and JSON formatted outputs optimized for Claude.
- Cross-API Compatibility: Works seamlessly with Claude, Grok, and OpenAI APIs.
- Schema-aware Auto-complete Prompts: Ensure prompts are schema-compliant using auto-completion features.
- Streaming Input Parsing: Efficiently parse streaming inputs directly in Claude Desktop.
Installation Instructions
To install mcp_prompt_mapper, you can use pip:
pip install mcp_prompt_mapper
Alternatively, if you prefer to install from the source, clone this repository and run setup.py:
git clone https://github.com/your-repo/mcp_prompt_mapper.git
cd mcp_prompt_mapper
python setup.py install
Usage Examples
Basic Example
Here is a simple example of how to use mcp_prompt_mapper with default settings.
from mcp_prompt_mapper import PromptMapper
# Initialize the PromptMapper
prompt_mapper = PromptMapper()
# Sample input from mcp_input_analyzer
input_data = {
"resource_type": "database",
"tool_name": "sql_query_tool"
}
# Generate prompts
prompts = prompt_mapper.generate_prompts(input_data)
print(prompts)
Advanced Example with Custom Output Format
This example demonstrates how to generate prompts in YAML format.
from mcp_prompt_mapper import PromptMapper
# Initialize the PromptMapper with YAML output format
prompt_mapper = PromptMapper(output_format='yaml')
# Sample input from mcp_input_analyzer
input_data = {
"resource_type": "api_gateway",
"tool_name": "http_request_tool"
}
# Generate prompts
prompts = prompt_mapper.generate_prompts(input_data)
print(prompts)
Streaming Input Example
Here's how you can handle streaming input for Claude Desktop.
from mcp_prompt_mapper import PromptMapper
# Initialize the PromptMapper with YAML output format
prompt_mapper = PromptMapper(output_format='yaml')
# Simulate streaming input
streaming_input = [
{"resource_type": "database", "tool_name": "sql_query_tool"},
{"resource_type": "api_gateway", "tool_name": "http_request_tool"}
]
for data in streaming_input:
prompts = prompt_mapper.generate_prompts(data)
print(prompts)
API Documentation
Class PromptMapper
-
Initialization
__init__(self, output_format='json'): Initializes the PromptMapper instance. Accepts an optionaloutput_formatparameter that defaults to'json'. Supported values are'json'and'yaml'.
-
Method
generate_promptsgenerate_prompts(self, input_data): Takes a dictionary of input data and generates prompts based on the provided schema. Returns the generated prompts in the specified output format.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Ensure you replace `"https://github.com/your-repo/mcp_prompt_mapper.git"` with the actual URL of your repository if it's different. Additionally, ensure that any other paths or references are correctly updated to match your project setup.
## ⚠️ Development Status
This library is currently in early development. Some tests may be failing with the following issues:
Contributions to fix these issues are welcome! Please submit a pull request if you have a solution.
Comments
New to MCP?
From what the protocol is to installing your first server, these answers cover most first questions.
An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.