Skip to main content
Glama
jankowtf

MCP Server Template for Cursor IDE

by jankowtf

fetch_railway_docs_optimized

Retrieve Railway CLI documentation directly within Cursor IDE. This tool fetches up-to-date documentation to help developers access CLI commands and usage information without leaving their development environment.

Instructions

Fetches the most recent Railway CLI documentation. Optionally, provide a custom URL.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlNoOptional custom URL for fetching Railway CLI docs.

Implementation Reference

  • The core handler function that fetches Railway CLI documentation from the given URL, parses the HTML using BeautifulSoup to extract CLI commands from headings and lists/code blocks, and returns optimized text content.
    async def fetch_railway_docs_optimized(
        url: str = "https://docs.railway.app/guides/cli",
    ) -> list[types.TextContent]:
        headers = {
            "User-Agent": "MCP Railway Docs Fetcher (github.com/modelcontextprotocol/python-sdk)"
        }
    
        try:
            timeout = httpx.Timeout(10.0, connect=5.0)
            async with httpx.AsyncClient(
                follow_redirects=True, headers=headers, timeout=timeout
            ) as client:
                response = await client.get(url)
                response.raise_for_status()
    
                # Parse HTML content
                soup = BeautifulSoup(response.text, "html.parser")
                content = []
    
                # Try to find any command sections
                for heading in soup.find_all(["h1", "h2", "h3", "h4"]):
                    heading_text = heading.get_text(strip=True).lower()
                    if any(
                        keyword in heading_text for keyword in ["command", "cli", "usage"]
                    ):
                        # Look for the next element that might contain commands
                        next_elem = heading.find_next_sibling()
                        while next_elem and next_elem.name not in [
                            "ul",
                            "ol",
                            "h1",
                            "h2",
                            "h3",
                            "h4",
                        ]:
                            next_elem = next_elem.find_next_sibling()
    
                        if next_elem and next_elem.name in ["ul", "ol"]:
                            commands = []
                            for li in next_elem.find_all("li"):
                                cmd_text = li.get_text(strip=True)
                                if cmd_text:  # Only add non-empty commands
                                    commands.append(cmd_text)
    
                            if commands:  # Only add sections that have commands
                                content.append(f"\n{heading.get_text(strip=True)}:")
                                content.extend(f"- {cmd}" for cmd in commands)
    
                if content:
                    return [types.TextContent(type="text", text="\n".join(content))]
    
                # If we couldn't find any command sections, try to extract any code blocks
                code_blocks = soup.find_all(["pre", "code"])
                if code_blocks:
                    content = ["Railway CLI Commands:"]
                    for block in code_blocks:
                        code_text = block.get_text(strip=True)
                        if code_text and any(
                            keyword in code_text.lower() for keyword in ["railway", "cli"]
                        ):
                            content.append(code_text)
                    return [types.TextContent(type="text", text="\n".join(content))]
    
                # If still nothing found, return a more helpful message
                return [
                    types.TextContent(
                        type="text",
                        text="Could not find any CLI commands in the documentation. The page structure might have changed.",
                    )
                ]
        except Exception as e:
            return [
                types.TextContent(
                    type="text",
                    text=f"Error: Failed to fetch or parse Railway CLI docs: {str(e)}",
                )
            ]
  • Dispatch registration in the @app.call_tool() handler (fetch_tool function) that routes calls to the fetch_railway_docs_optimized function when the tool name matches.
    if name == "fetch_railway_docs_optimized":
        url = arguments.get("url", "https://docs.railway.app/guides/cli")
        return await fetch_railway_docs_optimized(url)
  • Tool schema and metadata registration in the @app.list_tools() function, defining the tool name, description, and optional 'url' input schema.
    types.Tool(
        name="fetch_railway_docs_optimized",
        description="Fetches the most recent Railway CLI documentation. Optionally, provide a custom URL.",
        inputSchema={
            "type": "object",
            "properties": {
                "url": {
                    "type": "string",
                    "description": "Optional custom URL for fetching Railway CLI docs.",
                },
            },
        },
    ),
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool fetches documentation but doesn't describe how it handles errors, rate limits, authentication needs, or what 'optimized' entails (e.g., caching, performance). This leaves significant gaps in understanding the tool's behavior beyond basic functionality.

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 two sentences that directly state the tool's purpose and parameter usage. It is front-loaded with the main action and avoids any unnecessary details, making it efficient and easy to parse.

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

Completeness3/5

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

Given the tool's low complexity (one optional parameter, no output schema, no annotations), the description is minimally complete but lacks depth. It covers the basic purpose and parameter but misses behavioral details like error handling or optimization specifics, which are needed for full contextual understanding despite the simple schema.

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

Parameters4/5

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

The description adds value by explaining the optional custom URL parameter's purpose ('for fetching Railway CLI docs'), which complements the schema's 100% coverage. Since there's only one parameter and the schema already describes it well, the description provides adequate semantic context without redundancy, earning a high score.

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

Purpose4/5

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

The description clearly states the tool's purpose with a specific verb ('fetches') and resource ('most recent Railway CLI documentation'), and distinguishes it from the sibling 'fetch_railway_docs' by indicating optimization. However, it doesn't fully explain how it differs beyond the optional URL parameter, keeping it from a perfect score.

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

Usage Guidelines3/5

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

The description implies usage by mentioning the optional custom URL, suggesting it's for fetching docs with potential customization. However, it lacks explicit guidance on when to use this tool versus the sibling 'fetch_railway_docs' or other tools, and doesn't specify prerequisites or exclusions, leaving usage context vague.

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/jankowtf/mcp-hitchcode'

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