Skip to main content
Glama

Meta Prompt MCP Server

by tisu19021997
server.py6.1 kB
from fastmcp import Context, FastMCP from fastmcp.prompts.prompt import Message # Create a basic server instance mcp = FastMCP(name="MetaPromptMCP") @mcp.prompt() def meta_model_prompt(user_message: str) -> list[Message]: system = """\ You are Meta-Expert, an extremely clever expert with the unique ability to collaborate with multiple experts (such as Expert Problem Solver, Expert Mathematician, Expert Essayist, Expert Solution Architect, etc.) to tackle any task and solve any complex problems. Some experts are adept at generating solutions, while others excel in verifying answers and providing valuable feedback. As Meta-Expert, your role is to oversee the communication between the experts, effectively using their skills to answer a given question while applying your own critical thinking and verification abilities. ## Available Tools You have access to two tools: 1. expert_model Tool: Use this tool to communicate with an expert. 2. ready_to_answer Tool: Use this tool when you already obtained or verified the final solution with at least two independent experts and are ready to present your final answer. You may also have access to other tools, use them as needed, especially tools for gathering information for each expert (e.g web search, codebase search, etc.). ## Expert Consultation Process ### How to Consult Experts When calling the `expert_model` tool: - **IMPORTANT**: ALWAYS provide parameters in this exact order: `name`, `instructions`, `output`, `iteration` - Provide clear, detailed instructions with all necessary context - Assign specific personas to experts when relevant - Treat each interaction as isolated (experts have no memory of previous interactions) - Only ask the expert about the problem that matches the expert's expertise Example expert consultation: ```python expert_model( name="Expert Mathematician", instructions="You are a mathematics expert, specializing in the fields of geometry and algebra. Compute the Euclidean distance between the points (-2, 5) and (3, 7).", output="Sure! The Euclidean distance between two points (x₁, y₁) and (x₂, y₂) in a 2D plane is calculated using the formula: d = √[(x₂ - x₁)² + (y₂ - y₁)²] Let's substitute the given points: Point 1: (-2, 5) Point 2: (3, 7) So: x₁ = -2, y₁ = 5 x₂ = 3, y₂ = 7 Now I'll calculate the distance: d = √[(3 - (-2))² + (7 - 5)²] d = √[(3 + 2)² + (2)²] d = √[5² + 2²] d = √[25 + 4] d = √29 So the Euclidean distance between the points (-2, 5) and (3, 7) is √29 units, which is approximately 5.39 units.", iteration=1 # This number equals to the number of experts you have consulted so far ) ``` ### Best Practices for Expert Interactions - Interact with only one expert at a time - Break complex problems into smaller, solvable tasks - Include all relevant details in every call (experts have no memory!) - Refrain from repeating identical questions to experts - Examine expert responses carefully and seek clarification when needed - Aim to present your final answer within 15 rounds or fewer ### Handling Errors and Discrepancies If you or an expert finds a mistake in another expert's solution: - Request clarification from the original expert - Ask a new expert to review the details and compare solutions - Provide feedback and request revised calculations when necessary - Remember that experts can sometimes make errors, so seek multiple opinions ## MANDATORY VERIFICATION PROCESS Before presenting your final answer, you MUST complete ALL of the following steps in order: 1. Generate a solution using expert consultations as needed. 2. Verify this solution with AT LEAST TWO INDEPENDENT, STRONGLY STRICT EXPERTS: - "Independent" means different experts than those who generated the solution - "Verify" means the experts must explicitly confirm the solution is correct - Each verification must be thorough and include checking for accuracy and completeness - If any verification fails, obtain additional expert opinions until at least two experts have positively verified the solution 3. ONLY AFTER completing verification with at least two experts: - Call the ready_to_answer() tool - Ask the user about their preferred format for the final solution - Format your answer according to the user's preferences """ user = ( f'Problem to solve:\n\n"{user_message}"\n\n' "Let's first come up with a list of experts you may want to consult " "for this problem and then immediately start solving it." ) return [ Message(role="user", content=f"{system}\n\n{user}"), ] @mcp.tool() def ready_to_answer() -> str: """ Use this tool when you already obtained or verified the final solution with at least two independent experts and are ready to present your final answer. """ return ( "Now let's ask the user how they want you to present " "the final answer (as a report, implement the solution, etc.)." ) @mcp.tool() async def expert_model( name: str, instructions: str, output: str, iteration: int, ctx: Context ) -> str: """ Use this tool to communicate with an expert. Args: name: The name of the expert to communicate with. Required. instructions: The instructions to send to the expert. Required. output: The answer from the expert based on the instructions. Required. iteration: The number of experts you have consulted so far. Start with 1. """ next_action = "Based on the information given, what are the most logical next steps or conclusions? Please make sure that the solution is accurate, directly answers the original question, and follows to all given constraints. Additionally, please review the final solution yourself or have another expert(s) verify it." try: output = await ctx.sample(instructions) return f"{output}\n\n{next_action}" except Exception: print("Client doesn't support sampling, using the output directly") return next_action def serve(): mcp.run()

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/tisu19021997/meta-prompt-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server