Up-to-date · Local-first · Low-hallucination
context9-introduction-compressed.mov
- 🎯 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.
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.
docker run -d \
--name context9 \
-p 8011:8011 \
--restart unless-stopped \
ghcr.io/prism-shadow/context9:latest \
python -m context9.server --github_sync_interval 600Or 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 600Visit 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 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.
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.
You can test your configured Context9 instance by simply entering the current Context9 Server IP and API key in the MCP Inspector.
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.
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>"
}
}
}
}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>"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.
Add a prompt to CLAUDE.md to enable Context9:
- Always retrieve required documentation via Context9
Add rules to AGENTS.md, for example:
Rules:
- Always retrieve required documentation via Context9
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.
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.
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
Expand
Requirements
- Python >= 3.10
- Node.js >= 18
- Repository access (public or with authentication token)
git clone https://github.com/Prism-Shadow/context9.git && cd context9
# Install the package
uv sync
# Or install with development dependencies
uv sync --dev
cd gui
npm install
cd ..
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 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/
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.
Requirements
- Python >= 3.10
- Repository access (public or with authentication token)
- Optional: Webhook setup for event-based updates
git clone https://github.com/Prism-Shadow/context9.git && cd context9
# Install the package
uv sync
# Or install with development dependencies
uv sync --dev
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
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
# 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
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
Licensed under the Apache License, version 2.0. See LICENSE for details.
This repo benefits from context7. Thanks to the authors and contributors for their excellent work and inspiration.






