Comprehensive documentation for the gitea-robot Model Context Protocol (MCP) server, enabling AI agents to interact with Gitea task management through standardized tools.
- Overview
- Quick Start
- Environment Variables
- Available MCP Tools
- JSON-RPC 2.0 Protocol
- Integration Examples
- Troubleshooting
The gitea-robot MCP server exposes Gitea Robot AI functionality through the Model Context Protocol (MCP), a standardized interface for AI agent tool integration. The server runs as a stdio-based JSON-RPC 2.0 service that AI agents can connect to for:
- Task Prioritization: Get PageRank-scored task recommendations
- Dependency Management: View and modify issue dependencies
- Workflow Automation: Identify unblocked (ready) tasks automatically
AI Agent (Claude, Codex, etc.)
|
| JSON-RPC 2.0 over stdio
v
gitea-robot mcp-server
|
| HTTP/JSON API calls
v
Gitea Robot API (git.terraphim.cloud)
|
| Internal queries
v
Gitea Database & Issue Tracker
- Standardized Protocol: Uses MCP specification for universal AI agent compatibility
- PageRank Prioritization: Tasks ranked by impact on downstream work
- Dependency Awareness: Full visibility into issue blocking relationships
- Zero Configuration: Works with existing GITEA_URL and GITEA_TOKEN environment variables
# From the gitea repository root
go build -o gitea-robot cmd/gitea-robot/main.goexport GITEA_URL="https://git.terraphim.cloud"
export GITEA_TOKEN="your-api-token-here"./gitea-robot mcp-serverThe server will start and listen for JSON-RPC 2.0 messages on stdin, writing responses to stdout.
Send a ping request to verify the server is running:
{"jsonrpc": "2.0", "id": 1, "method": "ping"}Expected response:
{"jsonrpc": "2.0", "id": 1, "result": {}}| Variable | Required | Default | Description |
|---|---|---|---|
GITEA_URL |
No | http://localhost:3000 |
Base URL of your Gitea instance |
GITEA_TOKEN |
Yes | - | API token for authentication |
- Log into your Gitea instance
- Go to Settings -> Applications
- Generate a new token with
repoandissuescopes - Copy the token value
- Never commit tokens to version control
- Use environment files or secret management tools
- For local development, consider using 1Password CLI:
export GITEA_TOKEN=$(op read "op://TerraphimPlatform/gitea-test-token/credential")The MCP server exposes four tools that map directly to gitea-robot CLI commands:
Returns all issues ranked by PageRank score (highest impact first).
Input Schema:
{
"type": "object",
"properties": {
"owner": {
"type": "string",
"description": "Repository owner"
},
"repo": {
"type": "string",
"description": "Repository name"
},
"format": {
"type": "string",
"description": "Output format: json or markdown",
"default": "json"
}
},
"required": ["owner", "repo"]
}Example Request:
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "triage",
"arguments": {
"owner": "terraphim",
"repo": "gitea",
"format": "json"
}
}
}Example Response:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"quick_ref": {
"total": 42,
"open": 12,
"blocked": 3,
"ready": 5
},
"recommendations": [
{
"id": 123,
"index": 1,
"title": "Implement PageRank algorithm",
"pagerank": 0.8543,
"blocked_by": [],
"blocking": [456, 789]
}
]
}
}Returns only issues that are ready to work on (not blocked by dependencies).
Input Schema:
{
"type": "object",
"properties": {
"owner": {
"type": "string",
"description": "Repository owner"
},
"repo": {
"type": "string",
"description": "Repository name"
}
},
"required": ["owner", "repo"]
}Example Request:
{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/call",
"params": {
"name": "ready",
"arguments": {
"owner": "terraphim",
"repo": "gitea"
}
}
}Returns the complete dependency graph for a repository.
Input Schema:
{
"type": "object",
"properties": {
"owner": {
"type": "string",
"description": "Repository owner"
},
"repo": {
"type": "string",
"description": "Repository name"
}
},
"required": ["owner", "repo"]
}Example Request:
{
"jsonrpc": "2.0",
"id": 3,
"method": "tools/call",
"params": {
"name": "graph",
"arguments": {
"owner": "terraphim",
"repo": "gitea"
}
}
}Example Response:
{
"jsonrpc": "2.0",
"id": 3,
"result": {
"nodes": [
{"id": 1, "title": "Setup project", "status": "closed"},
{"id": 2, "title": "Implement feature", "status": "open"}
],
"edges": [
{"from": 1, "to": 2, "type": "blocks"}
]
}
}Creates a dependency relationship between two issues.
Input Schema:
{
"type": "object",
"properties": {
"owner": {
"type": "string",
"description": "Repository owner"
},
"repo": {
"type": "string",
"description": "Repository name"
},
"issue": {
"type": "integer",
"description": "Issue ID (the one being blocked)"
},
"blocks": {
"type": "integer",
"description": "Issue ID that blocks this issue"
},
"relates_to": {
"type": "integer",
"description": "Issue ID that relates to this issue"
}
},
"required": ["owner", "repo", "issue"]
}Example Request (blocking dependency):
{
"jsonrpc": "2.0",
"id": 4,
"method": "tools/call",
"params": {
"name": "add_dep",
"arguments": {
"owner": "terraphim",
"repo": "gitea",
"issue": 42,
"blocks": 10
}
}
}Example Response:
{
"jsonrpc": "2.0",
"id": 4,
"result": "Dependency added successfully\n"
}Note: Either blocks or relates_to must be provided, but not both.
The MCP server implements JSON-RPC 2.0 over stdio with newline-delimited messages.
All messages are single-line JSON objects terminated by a newline character (\n).
Called by the client to initialize the MCP session.
Request:
{
"jsonrpc": "2.0",
"id": 1,
"method": "initialize",
"params": {
"protocolVersion": "2024-11-05",
"capabilities": {},
"clientInfo": {
"name": "claude-code",
"version": "1.0.0"
}
}
}Response:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"protocolVersion": "2024-11-05",
"capabilities": {
"tools": {}
},
"serverInfo": {
"name": "gitea-robot",
"version": "1.0.0"
}
}
}Returns the list of available tools.
Request:
{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/list"
}Response:
Returns a list of all four tools with their input schemas (see Available MCP Tools).
Invokes a specific tool with provided arguments.
Request:
{
"jsonrpc": "2.0",
"id": 3,
"method": "tools/call",
"params": {
"name": "triage",
"arguments": {
"owner": "terraphim",
"repo": "gitea"
}
}
}Response:
Returns the tool-specific result or an error object.
Health check endpoint.
Request:
{
"jsonrpc": "2.0",
"id": 4,
"method": "ping"
}Response:
{
"jsonrpc": "2.0",
"id": 4,
"result": {}
}Error responses follow JSON-RPC 2.0 specification:
{
"jsonrpc": "2.0",
"id": 5,
"error": {
"code": -32602,
"message": "Missing required argument: owner"
}
}Common Error Codes:
| Code | Meaning | Description |
|---|---|---|
| -32703 | Parse error | Invalid JSON received |
| -32601 | Method not found | Unknown method or tool name |
| -32602 | Invalid params | Missing or invalid parameters |
| -32603 | Internal error | Server-side error |
Add to your Claude Code configuration (~/.claude/config.json):
{
"mcpServers": {
"gitea-robot": {
"command": "/path/to/gitea-robot",
"args": ["mcp-server"],
"env": {
"GITEA_URL": "https://git.terraphim.cloud",
"GITEA_TOKEN": "your-token-here"
}
}
}
}Add to your Opencode configuration (~/.opencode/config.json):
{
"mcpServers": {
"gitea-robot": {
"command": "/path/to/gitea-robot",
"args": ["mcp-server"],
"env": {
"GITEA_URL": "https://git.terraphim.cloud",
"GITEA_TOKEN": "your-token-here"
}
}
}
}Codex automatically detects MCP servers from common configuration locations. Ensure your configuration is in:
~/.codex/config.json~/.config/codex/config.json
With the same format as above.
For any MCP-compatible client, use this connection configuration:
{
"name": "gitea-robot",
"transport": "stdio",
"command": "/path/to/gitea-robot",
"arguments": ["mcp-server"],
"environment": {
"GITEA_URL": "https://git.terraphim.cloud",
"GITEA_TOKEN": "your-token-here"
}
}For debugging, you can manually test the MCP server:
# Terminal 1: Start the server
export GITEA_URL="https://git.terraphim.cloud"
export GITEA_TOKEN="your-token"
./gitea-robot mcp-server
# Terminal 2: Send JSON-RPC messages
echo '{"jsonrpc":"2.0","id":1,"method":"ping"}' | nc -q 0 localhost stdioProblem: ./gitea-robot mcp-server exits immediately
Solutions:
-
Check that
GITEA_TOKENis set:echo $GITEA_TOKEN
-
Verify the binary is built:
go build -o gitea-robot cmd/gitea-robot/main.go
-
Check for port conflicts (though MCP uses stdio, not TCP ports)
Problem: "Error: 401 Unauthorized" in responses
Solutions:
-
Verify your token is valid:
curl -H "Authorization: token $GITEA_TOKEN" \ "$GITEA_URL/api/v1/user"
-
Check token scopes (needs
repoandissueaccess) -
Ensure token hasn't expired
Problem: "Failed to parse JSON" errors
Solutions:
- Ensure messages are single-line JSON
- Check for proper JSON escaping
- Verify the newline character (
\n) is present at message end - Use jq to validate JSON:
echo '{"jsonrpc":"2.0","id":1,"method":"ping"}' | jq .
Problem: "Tool not found: triage"
Solutions:
- Check the tool name spelling (use underscore for
add_dep) - Verify you're using
tools/callmethod, not calling the tool name directly - List available tools to confirm:
{"jsonrpc":"2.0","id":1,"method":"tools/list"}
Problem: "Missing required argument: owner"
Solutions:
- Check the tool's input schema in Available MCP Tools
- Ensure all required fields are provided in the
argumentsobject - Verify parameter types (string vs integer)
Problem: Client can't connect to MCP server
Solutions:
- MCP uses stdio, not network ports - ensure client spawns the process correctly
- Check that the binary path is absolute in configuration
- Verify environment variables are passed through correctly
To see detailed error messages, run the server directly and send requests manually:
# Terminal 1
export GITEA_URL="https://git.terraphim.cloud"
export GITEA_TOKEN="your-token"
./gitea-robot mcp-server
# Then type requests manually:
{"jsonrpc":"2.0","id":1,"method":"tools/list"}Watch stderr for error messages that don't appear in JSON-RPC responses.
For additional support:
- Check the Gitea Robot CLI Testing Guide
- Review the Design Document
- Test the underlying API directly:
curl -H "Authorization: token $GITEA_TOKEN" \ "$GITEA_URL/api/v1/robot/triage?owner=terraphim&repo=gitea"
The gitea-robot binary supports both CLI and MCP server modes:
| Mode | Command | Use Case |
|---|---|---|
| CLI | gitea-robot triage --owner X --repo Y |
Manual use, scripts |
| CLI | gitea-robot ready --owner X --repo Y |
Manual use, scripts |
| CLI | gitea-robot graph --owner X --repo Y |
Manual use, scripts |
| CLI | gitea-robot add-dep --owner X --repo Y --issue N --blocks M |
Manual use, scripts |
| MCP | gitea-robot mcp-server |
AI agent integration |
Both modes use the same environment variables and access the same Gitea Robot API.
The triage tool uses PageRank algorithm to prioritize tasks:
- Higher score = More downstream impact
- Tasks that unblock many other tasks get higher priority
- Ready tasks (not blocked) with high PageRank should be tackled first
Example interpretation:
{
"pagerank": 0.85,
"blocking": [10, 20, 30]
}This task has a high PageRank (0.85) because it blocks 3 other issues. Completing it will unblock significant downstream work.
- Start with
ready: Always check ready tasks first before usingtriage - Use PageRank: Focus on high PageRank tasks to maximize impact
- Keep Dependencies Updated: Use
add_depto maintain accurate dependency chains - Regular Triage: Run triage daily to stay on top of changing priorities
- Graph Visualization: Use
graphto understand complex dependency relationships
Copyright 2026 The Gitea Authors. All rights reserved.
SPDX-License-Identifier: MIT