Skip to main content
DeepWiki (by Cognition) exposes an MCP server that reads and answers questions about the documentation of any public GitHub repository. It is free, needs no authentication, and is the best first MCP integration to write — the only key you need is the one for your LLM.

Prerequisites

  • Python 3.10+
  • One LLM provider key. This tutorial uses Anthropic; any LiteLLM model with tool-calling support works.

Build it

1

Install swarms

2

Set your LLM key

Only your model provider needs a key. DeepWiki itself is open.
3

Write a system prompt that forces grounding

An agent with a research tool will still answer from memory unless you tell it not to. This prompt is the difference between a citation and a guess:
4

Point the agent at the server

mcp_url is the entire integration. On startup the agent connects, fetches the server’s tool list, and converts each tool into a function-calling schema the model can use.
5

Run a task

The complete script

What happens when you call run()

  1. The agent connects over streamable HTTP, the default transport. You never configure it for this server.
  2. Tools are discovered. The agent asks the server what it exposes and converts each tool to an OpenAI-format function schema.
  3. The model chooses. It typically calls read_wiki_structure to see what exists, then read_wiki_contents or ask_question for the parts that matter.
  4. Results come back into the conversation, and the model writes its answer from them.

The smallest possible version

Strip the system prompt and you still have a working integration — useful for a first smoke test:

Troubleshooting

Two fixes, in order: say “use your tools” in the task, and put the instruction to retrieve before answering in the system prompt. Weaker models need both.
read_wiki_contents can take a while on a big repository. One tool call may run for tool_timeout seconds, 120 by default; raise it with mcp_config=MCPConnection(url="https://mcp.deepwiki.com/mcp", tool_timeout=300). mcp_timeout only bounds connecting and sending requests.
Your swarms predates mcp 2.x support, which renamed that function. Upgrade with pip install -U swarms; 15.0.1 and later work with both mcp 1.x and 2.x.

Next