Open-source infrastructure for engineering knowledge and context.
SourceAnt helps the agents and humans building your software remember how it works. Its open core models code structure, decisions, rules, system topology, API contracts, and review findings behind storage-neutral interfaces. MCP clients can manage and retrieve that context without requiring the hosted SourceAnt service.
Code review is one application of this shared knowledge layer. SourceAnt also supports coding agents, architecture exploration, contract analysis, repository automation, and custom engineering workflows.
- Knowledge management through MCP: Create, update, search, connect, and retrieve scoped engineering knowledge.
- Durable storage: Keep community knowledge in SourceAnt's existing SQL database. PostgreSQL is used in the normal deployment, while the existing SQLite fallback remains available for local use.
- Engineering context composition: Combine code, knowledge, software topology, contracts, and active review findings into bounded context packs.
- Replaceable adapters: Connect structural indexers, graph databases, or custom repositories without changing the core domain.
- Automated code reviews: Use the same context interfaces for GitHub review and repository automation.
- Model choice: Use Gemini, Anthropic Claude, OpenAI, DeepSeek, Mistral, and 100+ providers through LiteLLM.
- Plugin runtime: Extend SourceAnt with new integrations and workflows.
The included MCP server uses SourceAnt's configured database. Knowledge remains available after the MCP process restarts.
git clone https://github.com/sourceant/sourceant.git
cd sourceant
python -m pip install -r requirements.txt
sourceant db upgrade head
python -m src.mcp_serverThis stdio option is useful for a local MCP client. It follows the required DATABASE_URL, just like the SourceAnt HTTP server. Set STATELESS_MODE=true to use temporary in-memory knowledge instead.
Configure your MCP client to run python -m src.mcp_server from the repository directory. Use that client's documented format for a local stdio server.
The regular SourceAnt application can also serve MCP over Streamable HTTP at /mcp/. This transport is disabled unless all three authorization settings are present:
MCP_HTTP_ISSUER_URL=https://issuer.example.com
MCP_HTTP_RESOURCE_URL=https://sourceant.example.com/mcp/
MCP_HTTP_AUDIENCE=sourceant-mcp
MCP_HTTP_REQUIRED_SCOPES=sourceantJWT_SECRET remains the signing secret. Tokens must contain sub, exp, iss, aud, and a space-separated scope claim. Enabling MCP does not change the existing HTTP API or its authentication behavior.
HTTP knowledge is isolated by the authenticated principal and the requested scope. The server adds the principal boundary itself, so a client cannot select another principal through tool arguments.
The community server exposes these MCP tools:
| Tool | Purpose |
|---|---|
put_knowledge |
Create or update a decision, rule, constraint, convention, note, or another knowledge type. |
put_knowledge_relationship |
Connect knowledge with relationships such as depends_on, supports, or contradicts. |
search_knowledge |
Find knowledge by scope, identity, type, status, or properties. |
get_context |
Traverse related knowledge and combine it with other configured engineering context. |
Scopes are open key-value pairs. A personal project can use {"project": "shop"}. An integration can use repository, organization, customer, or another boundary without changing core types.
Example requests to an MCP-enabled coding agent:
Remember that project shop uses signed webhook requests. Store it as an approved decision.
Connect the signed webhook decision to the rule that rejects unsigned requests.
Get the approved knowledge related to the signed webhook decision before changing its handler.
The SQL repository is the basic community implementation. Applications can inject another KnowledgeRepository and the MCP tools continue to use the same contract.
Knowledge scopes can identify any repository. SourceAnt core does not clone or structurally index arbitrary repositories by itself. Code-aware context requires a CodeIndexReader integration, while knowledge management works without one.
- Python 3.10+
- GitHub account with a repository for testing.
- LLM API key (supports any LiteLLM-compatible provider: Gemini, Anthropic, DeepSeek, OpenAI, etc.).
-
Clone the Repository:
git clone https://github.com/sourceant/sourceant.git cd sourceant -
Initial project setup (docker-compose):
docker compose up -d
-
Install Dependencies:
docker compose exec app pip install -r requirements.txt -
Set Environment Variables: Copy
.env.exampleinto.envfile in the root directory and update the credentials accordingly:docker compose exec app cp .env.example .envGITHUB_WEBHOOK_SECRET=your_github_webhook_secret LLM_MODEL=gemini/gemini-2.5-flash LLM_TOKEN_LIMIT=1000000 GEMINI_API_KEY=your_gemini_api_key
SourceAnt API should be live at http://localhost:8000
The sourceant command provides the following subcommands for managing the application:
| Command | Description |
|---|---|
docker compose exec app sourceant db upgrade head |
Set up database tables |
docker compose exec app sourceant db --help |
See more database commands |
-
Start the database:
sourceant db
-
Start the API server:
docker compose up -d
-
Run the Worker:
docker compose exec app rq worker --url redis://redis:6379 -
View logs:
docker compose logs
The application can be configured using environment variables. Key variables are documented in the .env.example file.
SourceAnt uses LiteLLM to support 100+ LLM providers through a unified interface. Set the LLM_MODEL env var using the provider/model format:
| Provider | LLM_MODEL |
API Key Env Var |
|---|---|---|
| Google Gemini | gemini/gemini-2.5-flash |
GEMINI_API_KEY |
| Anthropic | anthropic/claude-sonnet-4-5-20250929 |
ANTHROPIC_API_KEY |
| OpenAI | openai/gpt-4o |
OPENAI_API_KEY |
| DeepSeek | deepseek/deepseek-chat |
DEEPSEEK_API_KEY |
# Example: switch from Gemini to Anthropic
LLM_MODEL=anthropic/claude-sonnet-4-5-20250929
ANTHROPIC_API_KEY=sk-ant-...See the full list of supported providers in the LiteLLM docs.
Authentication is handled via a GitHub App, which provides secure, repository-level access. Your setup path depends on whether you are using the official cloud service or self-hosting the backend.
If you are using the official SourceAnt cloud service, simply install our official GitHub App:
The app will request the necessary permissions, and once installed on your repositories, it will automatically send events to our hosted backend. No further configuration is needed. Manage your repositories, knowledge, and reviews from the dashboard at app.sourceant.ai.
If you are running your own instance of SourceAnt (e.g., from this repository), you must create your own GitHub App. This is because the webhook URL must point to your own server.
-
Create a New GitHub App:
- Navigate to your GitHub settings: Developer settings > GitHub Apps > New GitHub App.
- Webhook URL: Set this to the public URL of your backend, pointing to the webhook endpoint (e.g.,
https://your-domain.com/api/github/webhooks). - Webhook Secret: Generate a secure secret and save it. You will need this for the
GITHUB_SECRETenvironment variable.
-
Set Permissions: Under the "Permissions" tab for your app, grant the following access:
- Repository permissions > Contents:
Read-only - Repository permissions > Pull requests:
Read & write
- Repository permissions > Contents:
-
Generate a Private Key:
- At the bottom of your app's settings page, generate a new private key (
.pemfile). - Save this file securely and note its path.
- At the bottom of your app's settings page, generate a new private key (
-
Configure Environment Variables: Update your
.envfile with the credentials from the app you just created:GITHUB_APP_ID: The "App ID" from your app's settings page.GITHUB_APP_PRIVATE_KEY_PATH: The file path to the.pemprivate key you downloaded.GITHUB_SECRET: The webhook secret you created.
SourceAnt includes a builtin repo manager plugin that automates PR/issue triage and labeling. It is disabled by default. Enable it with environment variables:
| Variable | Default | Description |
|---|---|---|
REPO_MANAGER_ENABLED |
false |
Master switch for the repo manager |
REPO_MANAGER_PR_TRIAGE |
true |
Enable PR duplicate detection |
REPO_MANAGER_ISSUE_TRIAGE |
true |
Enable issue duplicate detection |
REPO_MANAGER_AUTO_LABEL |
true |
Enable auto-labeling |
Settings can also be configured per-repository using the Config model. See the Repo Management docs for details.
For development, testing, or specific use cases where you want to process events without writing them to the database, you can enable stateless mode. In this mode, the application will not attempt to connect to or interact with any database, making it lighter and preventing data accumulation.
To enable stateless mode, set the following environment variable:
STATELESS_MODE=trueThe LOG_DRIVER environment variable controls where the application logs are sent. This is particularly useful in serverless environments where file-based logging is not practical.
console(Default): Logs are sent to the console, intelligently routing tostdoutfor informational messages (INFO,DEBUG) andstderrfor warnings and errors (WARNING,ERROR,CRITICAL). This is the recommended setting for serverless and containerized environments like Cloud Run and Docker.file: Logs are written tosourceant.login the root directory. This is useful for traditional deployments where you have access to the file system.syslog: Logs are sent to the system's syslog daemon. This is suitable for environments where you want to centralize logs from multiple services into a single, system-level logging solution.
The application supports different backend modes for processing background jobs, controlled by the QUEUE_MODE environment variable.
-
redis(Default): This is the recommended mode for production. It uses a persistent Redis queue (rq) to handle background tasks. This requires a separaterqworker process to be running:docker compose exec app rq worker --url redis://redis:6379 -
redislite: A self-contained, file-based Redis queue. This mode is ideal for local development or testing as it provides the full functionality of a Redis queue without needing to run a separate Redis server. The Redis database file (redislite.db) will be created in the project root. -
request: This mode uses FastAPI'sBackgroundTasksto process jobs in the same process as the web request, after the response has been sent. It's the simplest mode for development as it requires no external worker or Redis, but it is not suitable for production as jobs are lost if the server restarts.
The base SourceAnt image is built automatically on merge to main and pushed to ghcr.io/sourceant/sourceant. You can also trigger a build manually via Actions → Build Image → Run workflow.
The enterprise image includes additional plugins and is built via manual dispatch.
Setup:
- Add a repository secret named
PLUGIN_REPO_TOKENcontaining a PAT with access to clone private plugin repositories. - Add a repository variable
ENTERPRISE_PLUGINSwith your plugin configuration:[{"name": "analytics", "repo": "sourceant/analytics"}]
Usage:
- Go to Actions → Build Enterprise Image → Run workflow.
- Leave the
pluginsinput empty to use theENTERPRISE_PLUGINSvariable, or override with a custom JSON array. - The image is pushed to
ghcr.io/sourceant/sourceant-enterprise:latest.
make prod-build # Build with default tag (:latest)
make prod-build IMAGE_TAG=v1.0.0 # Build with custom tag
make prod-push # Push to GHCR- Go to your GitHub repository.
- Navigate to Settings > Webhooks > Add Webhook.
- Set the Payload URL to your server's
/webhookendpoint (e.g.,https://your-server.com/webhook). - Set the Content type to
application/json. - Add the
GITHUB_WEBHOOK_SECRETto the Secret field. - Select Let me select individual events and choose Pull requests and Issues.
- Save the webhook.
We welcome contributions! Here's how you can help:
- Fork the repository.
- Create a new branch:
git checkout -b feature/your-feature. - Make your changes and commit them:
git commit -m 'Add some feature'. - Push to the branch:
git push origin feature/your-feature. - Submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.
Have questions or suggestions? Reach out to us:
- Email: hello@sourceant.ai
- GitHub Issues: Open an issue
Thanks to these amazing people who have contributed to this project:
Maintained by WhileSmart.