MCP server for reading docs from GitHub
Project description
Context9 - Bring Live Doc into Your Agent Context
Up-to-date · Local-first · Low-hallucination
https://github.com/user-attachments/assets/553ab8a2-5227-42fa-a8bd-692cd13c0b96
Why Context9?
- 🎯 Up-to-date knowledge: Real-time knowledge synchronization and reduce AI agent hallucinations.
- 🔐 Local-first: Fully open sourced and deploy on your own server, safely access your private knowledge.
- ⚙️ Easy-to-use Web UI: Easily manage your repositories and API-key permissions through the Context9 Panel.
What Context9 Actually Does
Context9 (Context Mine) is an MCP (Model Context Protocol) server. With local deployment, Context9 securely feeds agents with the most up-to-date documentation, reducing LLM hallucinations.
Install Context9
Run Context9 server
docker run -d \
--name context9 \
-p 8011:8011 \
--restart unless-stopped \
ghcr.io/prism-shadow/context9:latest \
python -m context9.server --github_sync_interval 600
Or you can specify the port on which Context9 runs.
docker run -d \
--name context9 \
-e CONTEXT9_PORT=<port> \
-p <port>:<port> \
--restart unless-stopped \
ghcr.io/prism-shadow/context9:latest \
python -m context9.server --github_sync_interval 600
Configure Context9
Login to Context9
Visit http://<server_ip>:8011/ to login to Context9
- Default username:
ctx9-admin - Default password:
88888888
Remember to change the default password when you first log in to Context9.
Add repositories
Add the repositories you need in Context9 by filling in the repository owner, repository name, and branch.
- For private repositories, you also need to provide a GitHub Token
Export & Import Repos using the Context9 template
- Export Repos: You can click the
Export Reposbutton to export the current repository configuration as a local template, making it easy to reuse later. - Import Repos: You can click the
Import Reposbutton to import a Context9 template into your repository configuration. Context9 also provides several templates for reference and use.
Add API Keys
Generate an API key that can be used to access Context9.
After generating the API key, you need to configure which repositories the API key is allowed to access.
Test Context9 (Optional)
You can test your configured Context9 instance by simply entering the current Context9 Server IP and API key in the MCP Inspector.
Integrate Context9 with Agent
After deploying the Context9 service, you can seamlessly integrate both private and public real-time code documentation into your agents. You can connect to the Context9 MCP service using tools such as Cursor and Claude Code.
Install in Cursor
Go to: Settings ->Cursor Settings -> Tools & MCP -> Add a Custom MCP Server
Paste the configuration below into ~/.cursor/mcp.json. If you want to configure Context9 for a specific project only, create .cursor/mcp.json in the project directory and paste the configuration there.
{
"mcpServers": {
"Context9": {
"url": "http://<server_ip>:8011/api/mcp/",
"headers": {
"Authorization": "Bearer <CTX9_API_KEY>"
}
}
}
}
Install in Claude Code
Run the following command to add Context9 to Claude Code.
claude mcp add --transport http Context9 http://<server_ip>:8011/api/mcp/ --header "Authorization: Bearer <CTX9_API_KEY>"
Suggestions for Context9 Usage
To avoid adding extra prompts every time you use Context9, we recommend that you:
- Use
CLAUDE.mdin Claude Code. - Use
AGENTS.mdfor Cursor, CodeX and other agents. - Add rules in Cursor.
Use CLAUDE.md for Claude Code
Add a prompt to CLAUDE.md to enable Context9:
- Always retrieve required documentation via Context9
Use AGENT.md for Cursor, CodeX and other agents
Add rules to AGENTS.md, for example:
Rules:
- Always retrieve required documentation via Context9
Add Rule for Cursor
Go to: Setting -> Rules and Commands -> Add Rule
Rule example:
Always use Context9 MCP to obtain the necessary documentation, regardless of whether I explicitly ask for it.
Work with Context9
Set up entry documentation
To enable Context9 to correctly discover and index your repository documentation, each repository should provide a Spec document. By default, Context9 expects a file named spec.md at the root of the repository.
your-repo/
├── spec.md ← Specification entry point
├── README.md
├── docs/
│ └── ...
└── ...
If you need to use a different filename or path, remember to update the repository configuration.
Use relative link in documentation
You do not need to think about MCP, indexing, or document resolution. Just maintain documentation links using normal repository-relative paths, exactly as you would for human readers.
Example in documentation.
## Related Documents
- [Detailed Guide](docs/detailed-guide.md)
- [API Reference](guides/api-reference.md)
- [FAQ](faq.md)
As long as these links are valid within the repository, Context9 will:
- Discover the documents
- Index them correctly
- Make them available to AI agents in real time
Deploy Context9 from source
Expand
GUI Deployment
Requirements
- Python >= 3.10
- Node.js >= 18
- Repository access (public or with authentication token)
Clone Context9 repository
git clone https://github.com/Prism-Shadow/context9.git && cd context9
Set up python environment
# Install the package
uv sync
# Or install with development dependencies
uv sync --dev
Install frontend dependencies
cd gui
npm install
cd ..
Configure Environment
Set the following environment variables (create a .env file, see .env example or export them directly):
CONTEXT9_PORT(Optional): Specifies the port number on which the Context9 service runs. Defaults to 8011.
CONTEXT9_PORT=xxxx
Build GUI and launch server
# Build frontend and start backend (serves GUI + API on the same port)
# Server is running on port 8011, visit http://<server_ip>:8011/
uv run python scripts/start.py --github_sync_interval 600
# Update repos every 60 seconds
uv run python scripts/start.py --github_sync_interval 60
Once started, open the GUI at: http://<server_ip>:8011/
Launch Context9 GUI with Docker
You can also run the GUI deployment using Docker. Context9 provides a ready-to-use Dockerfile.
# Build docker image
docker build -f docker/Dockerfile -t context9-gui:latest .
# Run docker container
docker run -d \
--name context9-gui \
-p 8011:8011 \
--env-file .env \
--restart unless-stopped \
context9-gui:latest \
python -m context9.server --github_sync_interval 600
The GUI and API are served from the same port. Open http://<server_ip>:8011/ in your browser.
The default login username is ctx9-admin, and the default password is 88888888. Change password when you login to Context9.
CLI Deployment
Requirements
- Python >= 3.10
- Repository access (public or with authentication token)
- Optional: Webhook setup for event-based updates
Clone Context9 repository
git clone https://github.com/Prism-Shadow/context9.git && cd context9
Set up python environment
# Install the package
uv sync
# Or install with development dependencies
uv sync --dev
Configure repository
Configure the repositories you need in config.yaml (private & public repositories)
An example of config.yaml file. config example
# config.yaml
repos:
# Private Repo 1
- owner: OwnerName
repo: RepoName
branch: BranchName
root_spec_path: RootSpecPath
# Private Repo 2 (Default root_spec_path is spec.md)
- owner: OwnerName
repo: RepoName
branch: BranchName
# Public Repo 1 (Example: sglang)
- owner: sgl-project
repo: sglang
branch: main
root_spec_path: README.md
You can include both private and public repositories.
Configure public repos
Simply specify the repository owner, name, and branch in config.yaml.
Configure private repos
-
Specify the repository owner, name, and branch in
config.yaml. - Add an authentication token with repository access permissions to your environment. Configure environment
Configure Environment
Set the following environment variables (create a .env file or export them directly):
CTX9_API_KEY(Required): API key used for server authentication to access private resources. Specified by an administrator. Keep it random and confidential.GITHUB_TOKEN(Optional): Required when configuring private repositories inconfig.yaml. This is not limited to a GitHub personal access token—any organization-issued repository access token is supported, as long as it conforms to the GitHub API specification.CONTEXT9_PORT(Optional): Specifies the port number on which the Context9 MCP service runs. If not specified, it defaults to 8011.
An example of .env file. .env example
GITHUB_TOKEN=github_token
CTX9_API_KEY=XXXXXXXXXXXXXXXX
# Optional
CONTEXT9_PORT=8080
Launch Context9 server
# Default:
# Sync repos every 600 seconds (10 minutes)
# Run server on port 8011
uv run python -m context9.server --config_file config.yaml
# Sync repos every 60 seconds (1 minute)
uv run python -m context9.server --github_sync_interval 60 --config_file config.yaml
# Run server on port 8080 (or define CONTEXT9_PORT in .env)
CONTEXT9_PORT=8080 uv run python -m context9.server --config_file config.yaml
Launch Context9 Server with Docker
You can also run Context9 using Docker. Context9 provides a ready-to-use Dockerfile.
The config.yaml file is included in the Docker image during the build process, so there is no need to provide it again when starting the container.
# Build docker image
docker build -f docker/Dockerfile-cli -t context9:latest .
# Run docker container
# Change port mapping according to your .env
docker run -d \
--name context9 \
-p 8011:8011 \
--env-file .env \
--restart unless-stopped \
context9:latest
License
Licensed under the Apache License, version 2.0. See LICENSE for details.
Acknowledge
This repo benefits from context7. Thanks to the authors and contributors for their excellent work and inspiration.
⭐ Star History
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file iflow_mcp_prism_shadow_context9-0.1.0.tar.gz.
File metadata
- Download URL: iflow_mcp_prism_shadow_context9-0.1.0.tar.gz
- Upload date:
- Size: 50.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a2d9dbfc376d9fa3ff697ff923b710ca658a06a37bc8e34f860b9ad3f559e3bd
|
|
| MD5 |
fd5dde535cd4109dd56092dc737a1bf8
|
|
| BLAKE2b-256 |
3d870059b43ce1ba5a920dbb7ae9e66c676d2259ac2501a4d095e406d07e946f
|
File details
Details for the file iflow_mcp_prism_shadow_context9-0.1.0-py3-none-any.whl.
File metadata
- Download URL: iflow_mcp_prism_shadow_context9-0.1.0-py3-none-any.whl
- Upload date:
- Size: 50.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ceea98da200d22e458542d6eb7af61a440c882ee6a764b1951d6b3f96b735eae
|
|
| MD5 |
592aef0b68a7f46710fb90a4c8a22521
|
|
| BLAKE2b-256 |
fce3ba4bf2fc47258fbea88252f823a02026a3daebbad268367e4a296b64203e
|