Skip to main content
Glama
chatmcp

mcp-server-collector

by chatmcp

extract-mcp-servers-from-content

Extract MCP servers from content by analyzing text to identify and collect server information for integration with the mcp-server-collector system.

Instructions

Extract MCP Servers from given content

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentYescontent containing mcp servers

Implementation Reference

  • Core handler function that uses OpenAI to extract MCP servers from the provided content using a JSON-structured prompt.
    async def extract_mcp_servers_from_content(content: str) -> str | None:
        client = OpenAI(
            api_key=os.getenv("OPENAI_API_KEY"),
            base_url=os.getenv("OPENAI_BASE_URL"),
        )
    
        user_content = extract_mcp_servers_prompt.format(content=content)
    
        logger.info(f"Extract prompt: {user_content}")
    
        chat_completion = client.chat.completions.create(
            messages=[
                {
                    "role": "user",
                    "content": user_content,
                }
            ],
            model=os.getenv("OPENAI_MODEL"),
            response_format={"type": "json_object"},
        )
    
        return chat_completion.choices[0].message.content
  • Registers the tool in the MCP server's list_tools() method, defining name, description, and input schema.
    types.Tool(
        name="extract-mcp-servers-from-content",
        description="Extract MCP Servers from given content",
        inputSchema={
            "type": "object",
            "properties": {
                "content": {
                    "type": "string",
                    "description": "content containing mcp servers",
                },
            },
            "required": ["content"],
        },
    ),
  • Input schema defining the expected 'content' parameter for the tool.
    inputSchema={
        "type": "object",
        "properties": {
            "content": {
                "type": "string",
                "description": "content containing mcp servers",
            },
        },
        "required": ["content"],
    },
  • MCP server call_tool handler that dispatches to extract logic for this tool and formats the response.
    @server.call_tool()
    async def handle_call_tool(
        name: str, arguments: dict | None
    ) -> list[types.TextContent | types.ImageContent | types.EmbeddedResource]:
        if not arguments:
            raise ValueError("Missing arguments")
    
        content = None
        
        match name:
            case "extract-mcp-servers-from-url":
                url = arguments.get("url")
                if not url:
                    raise ValueError("Missing url")
    
                content = await call_fetch_tool(url)
                
            case "extract-mcp-servers-from-content":
                content = arguments.get("content")
                
            case "submit-mcp-server":
                url = arguments.get("url")
                avatar_url = arguments.get("avatar_url") or ""
                result = await submit_mcp_server(url, avatar_url)
                content = json.dumps(result)
    
                return [
                    types.TextContent(
                        type="text",
                        text=content,
                    )
                ]
            case _:
                raise ValueError(f"Unknown tool: {name}")
    
        if not content:
            raise ValueError("Missing content")
    
        logger.info(f"Fetched content from {url}: {content}")
    
        mcp_servers = await extract_mcp_servers_from_content(content)
        if not mcp_servers:
            raise ValueError("Extracted no MCP Servers")
    
        logger.info(f"Extracted MCP Servers from {url}: {mcp_servers}")
    
        return [
            types.TextContent(
                type="text",
                text=mcp_servers,
            )
        ]   
  • Prompt template used in the extraction handler to guide the LLM in parsing MCP server details from content.
    extract_mcp_servers_prompt = """Please extract all MCP Servers from the following content and return a JSON array. Each item should contain:
    - name: extracted from the repository name in the URL
    - title: a human readable title
    - description: a brief description of the server
    - url: the full GitHub repository URL
    - author_name: extracted from the GitHub username in the URL
    
    Example response format:
    [
        {{
            "name": "mcp-server-example",
            "title": "MCP Server Example",
            "description": "A sample MCP server implementation",
            "url": "https://github.com/username/mcp-server-example",
            "author_name": "username"
        }}
    ]
    
    Content to analyze:
    {content}
    """
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It only states what the tool does ('extract MCP servers') without explaining how it behaves: e.g., what format the extraction outputs, whether it's read-only or has side effects, error handling, or performance considerations. This is inadequate for a tool with no annotation coverage, as it leaves critical behavioral traits unspecified.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise with a single sentence: 'Extract MCP Servers from given content'. It is front-loaded and wastes no words, making it easy to parse. Every part of the sentence earns its place by stating the action and target, though it could benefit from more detail for clarity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of extraction tasks, lack of annotations, and no output schema, the description is incomplete. It doesn't explain what 'extract' entails (e.g., parsing, formatting, or validation), what the output looks like, or how it differs from sibling tools. For a tool with no structured support beyond the input schema, this leaves significant gaps in understanding its full context and usage.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds no meaning beyond what the input schema provides. The schema has 100% coverage with one parameter 'content' described as 'content containing mcp servers', which the description implicitly references but doesn't elaborate on. With high schema coverage, the baseline is 3, as the schema already documents the parameter adequately, and the description doesn't compensate with additional context like examples or constraints.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states the tool's purpose as extracting MCP servers from content, which is clear but vague. It specifies the verb 'extract' and resource 'MCP servers', but doesn't differentiate from sibling tools like 'extract-mcp-servers-from-url' or 'submit-mcp-server' beyond the input source. The purpose is understandable but lacks specificity about what constitutes 'extraction' versus other operations.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention when to prefer this tool over 'extract-mcp-servers-from-url' (e.g., for direct content vs. URL fetching) or 'submit-mcp-server' (e.g., for extraction vs. submission). There's no context on prerequisites, exclusions, or typical use cases, leaving the agent to infer usage from the tool name alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

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/chatmcp/mcp-server-collector'

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