{"id":26512062,"url":"https://github.com/langchain-ai/mcpdoc","last_synced_at":"2025-04-06T22:08:58.905Z","repository":{"id":283001275,"uuid":"950361043","full_name":"langchain-ai/mcpdoc","owner":"langchain-ai","description":"Expose llms-txt to IDEs for development","archived":false,"fork":false,"pushed_at":"2025-04-05T17:52:21.000Z","size":157,"stargazers_count":177,"open_issues_count":3,"forks_count":25,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-05T18:26:03.267Z","etag":null,"topics":["agents","claude-code","cursor","ide","llms","llms-txt"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/langchain-ai.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-18T03:28:17.000Z","updated_at":"2025-04-05T17:52:25.000Z","dependencies_parsed_at":null,"dependency_job_id":"e07d9d6e-17c6-4d7a-b035-f754aa5f850f","html_url":"https://github.com/langchain-ai/mcpdoc","commit_stats":null,"previous_names":["langchain-ai/mcpdoc"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/langchain-ai%2Fmcpdoc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/langchain-ai%2Fmcpdoc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/langchain-ai%2Fmcpdoc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/langchain-ai%2Fmcpdoc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/langchain-ai","download_url":"https://codeload.github.com/langchain-ai/mcpdoc/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247557767,"owners_count":20958047,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["agents","claude-code","cursor","ide","llms","llms-txt"],"created_at":"2025-03-21T03:18:45.572Z","updated_at":"2025-04-06T22:08:58.895Z","avatar_url":"https://github.com/langchain-ai.png","language":"Python","funding_links":[],"categories":["Python","Open-Source Repos \u0026 Tools","📚 Projects (1974 total)","🤖 AI/ML","Developer Tools","🦜 LangGraph 🕸️","Document Processing","HarmonyOS","Developer Tools Mcp Servers"],"sub_categories":["llms.txt Ecosystem","MCP Servers","How to Submit","Usage with IDEs","Windows Manager"],"readme":"# MCP LLMS-TXT Documentation Server\n\n## Overview\n\n[llms.txt](https://llmstxt.org/) is a website index for LLMs, providing background information, guidance, and links to detailed markdown files. IDEs like Cursor and Windsurf or apps like Claude Code/Desktop can use `llms.txt` to retrieve context for tasks. However, these apps use different built-in tools to read and process files like `llms.txt`. The retrieval process can be opaque, and there is not always a way to audit the tool calls or the context returned.\n\n[MCP](https://github.com/modelcontextprotocol) offers a way for developers to have *full control* over tools used by these applications. Here, we create [an open source MCP server](https://github.com/modelcontextprotocol) to provide MCP host applications (e.g., Cursor, Windsurf, Claude Code/Desktop) with (1) a user-defined list of `llms.txt` files and (2) a simple  `fetch_docs` tool read URLs within any of the provided `llms.txt` files. This allows the user to audit each tool call as well as the context returned. \n\n\u003cimg src=\"https://github.com/user-attachments/assets/736f8f55-833d-4200-b833-5fca01a09e1b\" width=\"60%\"\u003e\n\n## llms-txt\n\nYou can find llms.txt files for langgraph and langchain here:\n\n| Library          | llms.txt                                                                                                   |\n|------------------|------------------------------------------------------------------------------------------------------------|\n| LangGraph Python | [https://langchain-ai.github.io/langgraph/llms.txt](https://langchain-ai.github.io/langgraph/llms.txt)     |\n| LangGraph JS     | [https://langchain-ai.github.io/langgraphjs/llms.txt](https://langchain-ai.github.io/langgraphjs/llms.txt) |\n| LangChain Python | [https://python.langchain.com/llms.txt](https://python.langchain.com/llms.txt)                             |\n| LangChain JS     | [https://js.langchain.com/llms.txt](https://js.langchain.com/llms.txt)                                     |\n\n## Quickstart\n\n#### Install uv\n* Please see [official uv docs](https://docs.astral.sh/uv/getting-started/installation/#installation-methods) for other ways to install `uv`.\n\n```bash\ncurl -LsSf https://astral.sh/uv/install.sh | sh\n```\n\n#### Choose an `llms.txt` file to use. \n* For example, [here's](https://langchain-ai.github.io/langgraph/llms.txt) the LangGraph `llms.txt` file.\n\n\u003e **Note: Security and Domain Access Control**\n\u003e \n\u003e For security reasons, mcpdoc implements strict domain access controls:\n\u003e \n\u003e 1. **Remote llms.txt files**: When you specify a remote llms.txt URL (e.g., `https://langchain-ai.github.io/langgraph/llms.txt`), mcpdoc automatically adds only that specific domain (`langchain-ai.github.io`) to the allowed domains list. This means the tool can only fetch documentation from URLs on that domain.\n\u003e \n\u003e 2. **Local llms.txt files**: When using a local file, NO domains are automatically added to the allowed list. You MUST explicitly specify which domains to allow using the `--allowed-domains` parameter.\n\u003e \n\u003e 3. **Adding additional domains**: To allow fetching from domains beyond those automatically included:\n\u003e    - Use `--allowed-domains domain1.com domain2.com` to add specific domains\n\u003e    - Use `--allowed-domains '*'` to allow all domains (use with caution)\n\u003e \n\u003e This security measure prevents unauthorized access to domains not explicitly approved by the user, ensuring that documentation can only be retrieved from trusted sources.\n\n#### (Optional) Test the MCP server locally with your `llms.txt` file(s) of choice:\n```bash\nuvx --from mcpdoc mcpdoc \\\n    --urls \"LangGraph:https://langchain-ai.github.io/langgraph/llms.txt\" \"LangChain:https://python.langchain.com/llms.txt\" \\\n    --transport sse \\\n    --port 8082 \\\n    --host localhost\n```\n\n* This should run at: http://localhost:8082\n\n![Screenshot 2025-03-18 at 3 29 30 PM](https://github.com/user-attachments/assets/24a3d483-cd7a-4c7e-a4f7-893df70e888f)\n\n* Run [MCP inspector](https://modelcontextprotocol.io/docs/tools/inspector) and connect to the running server:\n```bash\nnpx @modelcontextprotocol/inspector\n```\n\n![Screenshot 2025-03-18 at 3 30 30 PM](https://github.com/user-attachments/assets/14645d57-1b52-4a5e-abfe-8e7756772704)\n\n* Here, you can test the `tool` calls. \n\n#### Connect to Cursor \n\n* Open `Cursor Settings` and `MCP` tab.\n* This will open the `~/.cursor/mcp.json` file.\n\n![Screenshot 2025-03-19 at 11 01 31 AM](https://github.com/user-attachments/assets/3d1c8eb3-4d40-487f-8bad-3f9e660f770a)\n\n* Paste the following into the file (we use the `langgraph-docs-mcp` name and link to the LangGraph `llms.txt`).\n\n```\n{\n  \"mcpServers\": {\n    \"langgraph-docs-mcp\": {\n      \"command\": \"uvx\",\n      \"args\": [\n        \"--from\",\n        \"mcpdoc\",\n        \"mcpdoc\",\n        \"--urls\",\n        \"LangGraph:https://langchain-ai.github.io/langgraph/llms.txt LangChain:https://python.langchain.com/llms.txt\",\n        \"--transport\",\n        \"stdio\"\n      ]\n    }\n  }\n}\n```\n\n* Confirm that the server is running in your `Cursor Settings/MCP` tab.\n* Best practice is to then update Cursor Global (User) rules.\n* Open Cursor `Settings/Rules` and update `User Rules` with the following (or similar):\n\n```\nfor ANY question about LangGraph, use the langgraph-docs-mcp server to help answer -- \n+ call list_doc_sources tool to get the available llms.txt file\n+ call fetch_docs tool to read it\n+ reflect on the urls in llms.txt \n+ reflect on the input question \n+ call fetch_docs on any urls relevant to the question\n+ use this to answer the question\n```\n\n* `CMD+L` (on Mac) to open chat.\n* Ensure `agent` is selected. \n\n![Screenshot 2025-03-18 at 1 56 54 PM](https://github.com/user-attachments/assets/0dd747d0-7ec0-43d2-b6ef-cdcf5a2a30bf)\n\nThen, try an example prompt, such as:\n```\nwhat are types of memory in LangGraph?\n```\n\n![Screenshot 2025-03-18 at 1 58 38 PM](https://github.com/user-attachments/assets/180966b5-ab03-4b78-8b5d-bab43f5954ed)\n\n### Connect to Windsurf\n\n* Open Cascade with `CMD+L` (on Mac).\n* Click `Configure MCP` to open the config file, `~/.codeium/windsurf/mcp_config.json`.\n* Update with `langgraph-docs-mcp` as noted above.\n\n![Screenshot 2025-03-19 at 11 02 52 AM](https://github.com/user-attachments/assets/d45b427c-1c1e-4602-820a-7161a310af24)\n\n* Update `Windsurf Rules/Global rules` with the following (or similar):\n\n```\nfor ANY question about LangGraph, use the langgraph-docs-mcp server to help answer -- \n+ call list_doc_sources tool to get the available llms.txt file\n+ call fetch_docs tool to read it\n+ reflect on the urls in llms.txt \n+ reflect on the input question \n+ call fetch_docs on any urls relevant to the question\n```\n\n![Screenshot 2025-03-18 at 2 02 12 PM](https://github.com/user-attachments/assets/5a29bd6a-ad9a-4c4a-a4d5-262c914c5276)\n\nThen, try the example prompt:\n* It will perform your tool calls.\n\n![Screenshot 2025-03-18 at 2 03 07 PM](https://github.com/user-attachments/assets/0e24e1b2-dc94-4153-b4fa-495fd768125b)\n\n### Connect to Claude Desktop\n\n* Open `Settings/Developer` to update `~/Library/Application\\ Support/Claude/claude_desktop_config.json`.\n* Update with `langgraph-docs-mcp` as noted above.\n* Restart Claude Desktop app.\n\n\u003e [!Note]\n\u003e If you run into issues with Python version incompatibility when trying to add MCPDoc tools to Claude Desktop, you can explicitly specify the filepath to `python` executable in the `uvx` command.\n\u003e\n\u003e \u003cdetails\u003e\n\u003e \u003csummary\u003eExample configuration\u003c/summary\u003e\n\u003e\n\u003e ```\n\u003e {\n\u003e   \"mcpServers\": {\n\u003e     \"langgraph-docs-mcp\": {\n\u003e       \"command\": \"uvx\",\n\u003e       \"args\": [\n\u003e         \"--python\",\n\u003e         \"/path/to/python\",\n\u003e         \"--from\",\n\u003e         \"mcpdoc\",\n\u003e         \"mcpdoc\",\n\u003e         \"--urls\",\n\u003e         \"LangGraph:https://langchain-ai.github.io/langgraph/llms.txt\",\n\u003e         \"--transport\",\n\u003e         \"stdio\"\n\u003e       ]\n\u003e     }\n\u003e   }\n\u003e }\n\u003e ```\n\u003e \u003c/details\u003e\n\n\u003e [!Note]\n\u003e Currently (3/21/25) it appears that Claude Desktop does not support `rules` for global rules, so appending the following to your prompt.\n\n```\n\u003crules\u003e\nfor ANY question about LangGraph, use the langgraph-docs-mcp server to help answer -- \n+ call list_doc_sources tool to get the available llms.txt file\n+ call fetch_docs tool to read it\n+ reflect on the urls in llms.txt \n+ reflect on the input question \n+ call fetch_docs on any urls relevant to the question\n\u003c/rules\u003e\n```\n\n![Screenshot 2025-03-18 at 2 05 54 PM](https://github.com/user-attachments/assets/228d96b6-8fb3-4385-8399-3e42fa08b128)\n\n* You will see your tools visible in the bottom right of your chat input.\n\n![Screenshot 2025-03-18 at 2 05 39 PM](https://github.com/user-attachments/assets/71f3c507-91b2-4fa7-9bd1-ac9cbed73cfb)\n\nThen, try the example prompt:\n\n* It will ask to approve tool calls as it processes your request.\n\n![Screenshot 2025-03-18 at 2 06 54 PM](https://github.com/user-attachments/assets/59b3a010-94fa-4a4d-b650-5cd449afeec0)\n\n### Connect to Claude Code\n\n* In a terminal after installing [Claude Code](https://docs.anthropic.com/en/docs/agents-and-tools/claude-code/overview), run this command to add the MCP server to your project:\n```\nclaude mcp add-json langgraph-docs '{\"type\":\"stdio\",\"command\":\"uvx\" ,\"args\":[\"--from\", \"mcpdoc\", \"mcpdoc\", \"--urls\", \"langgraph:https://langchain-ai.github.io/langgraph/llms.txt\", \"--urls\", \"LangChain:https://python.langchain.com/llms.txt\"]}' -s local\n```\n* You will see `~/.claude.json` updated.\n* Test by launching Claude Code and running to view your tools:\n```\n$ Claude\n$ /mcp \n```\n\n![Screenshot 2025-03-18 at 2 13 49 PM](https://github.com/user-attachments/assets/eb876a0e-27b4-480e-8c37-0f683f878616)\n\n\u003e [!Note]\n\u003e Currently (3/21/25) it appears that Claude Code does not support `rules` for global rules, so appending the following to your prompt.\n\n```\n\u003crules\u003e\nfor ANY question about LangGraph, use the langgraph-docs-mcp server to help answer -- \n+ call list_doc_sources tool to get the available llms.txt file\n+ call fetch_docs tool to read it\n+ reflect on the urls in llms.txt \n+ reflect on the input question \n+ call fetch_docs on any urls relevant to the question\n\u003c/rules\u003e\n```\n\nThen, try the example prompt:\n\n* It will ask to approve tool calls.\n\n![Screenshot 2025-03-18 at 2 14 37 PM](https://github.com/user-attachments/assets/5b9a2938-ea69-4443-8d3b-09061faccad0)\n\n## Command-line Interface\n\nThe `mcpdoc` command provides a simple CLI for launching the documentation server. \n\nYou can specify documentation sources in three ways, and these can be combined:\n\n1. Using a YAML config file:\n\n* This will load the LangGraph Python documentation from the `sample_config.yaml` file in this repo.\n\n```bash\nmcpdoc --yaml sample_config.yaml\n```\n\n2. Using a JSON config file:\n\n* This will load the LangGraph Python documentation from the `sample_config.json` file in this repo.\n\n```bash\nmcpdoc --json sample_config.json\n```\n\n3. Directly specifying llms.txt URLs with optional names:\n\n* URLs can be specified either as plain URLs or with optional names using the format `name:url`.\n* You can specify multiple URLs by using the `--urls` parameter multiple times.\n* This is how we loaded `llms.txt` for the MCP server above.\n\n```bash\nmcpdoc --urls LangGraph:https://langchain-ai.github.io/langgraph/llms.txt --urls LangChain:https://python.langchain.com/llms.txt\n```\n\nYou can also combine these methods to merge documentation sources:\n\n```bash\nmcpdoc --yaml sample_config.yaml --json sample_config.json --urls LangGraph:https://langchain-ai.github.io/langgraph/llms.txt --urls LangChain:https://python.langchain.com/llms.txt\n```\n\n## Additional Options\n\n- `--follow-redirects`: Follow HTTP redirects (defaults to False)\n- `--timeout SECONDS`: HTTP request timeout in seconds (defaults to 10.0)\n\nExample with additional options:\n\n```bash\nmcpdoc --yaml sample_config.yaml --follow-redirects --timeout 15\n```\n\nThis will load the LangGraph Python documentation with a 15-second timeout and follow any HTTP redirects if necessary.\n\n## Configuration Format\n\nBoth YAML and JSON configuration files should contain a list of documentation sources. \n\nEach source must include an `llms_txt` URL and can optionally include a `name`:\n\n### YAML Configuration Example (sample_config.yaml)\n\n```yaml\n# Sample configuration for mcp-mcpdoc server\n# Each entry must have a llms_txt URL and optionally a name\n- name: LangGraph Python\n  llms_txt: https://langchain-ai.github.io/langgraph/llms.txt\n```\n\n### JSON Configuration Example (sample_config.json)\n\n```json\n[\n  {\n    \"name\": \"LangGraph Python\",\n    \"llms_txt\": \"https://langchain-ai.github.io/langgraph/llms.txt\"\n  }\n]\n```\n\n## Programmatic Usage\n\n```python\nfrom mcpdoc.main import create_server\n\n# Create a server with documentation sources\nserver = create_server(\n    [\n        {\n            \"name\": \"LangGraph Python\",\n            \"llms_txt\": \"https://langchain-ai.github.io/langgraph/llms.txt\",\n        },\n        # You can add multiple documentation sources\n        # {\n        #     \"name\": \"Another Documentation\",\n        #     \"llms_txt\": \"https://example.com/llms.txt\",\n        # },\n    ],\n    follow_redirects=True,\n    timeout=15.0,\n)\n\n# Run the server\nserver.run(transport=\"stdio\")\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flangchain-ai%2Fmcpdoc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flangchain-ai%2Fmcpdoc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flangchain-ai%2Fmcpdoc/lists"}