- mcp_prompt_mapper
mcp_prompt_mapper
mcp_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.