MCP Integration with Claude Code
Learn how to integrate AnyTask with Claude Code using the Model Context Protocol (MCP) for seamless AI agent collaboration.
This document describes how to integrate AnyTask with Claude Code using the Model Context Protocol (MCP).
Overview
The AnyTask MCP server exposes task management tools and resources to Claude Code, enabling seamless AI agent integration. Claude Code can:
- List and query tasks
- Create and update tasks
- Start and finish work attempts
- Upload artifacts (diffs, logs, files)
- Access task details, dependencies, and history
- Track active tasks across sessions
Prerequisites
- AnyTask Backend Running: Ensure the backend API is running (default: http://0.0.0.0:8000)
- Agent API Key: Create an agent API key for authentication
- Workspace: Have a workspace set up in AnyTask
Setup Instructions
Step 1: Create Agent API Key
# Login to AnyTask CLI first anyt auth login # Create an agent API key anyt auth agent-key create --name "claude-code" --permissions read,write,execute # Save the generated key (starts with anyt_agent_)
Step 2: Get Workspace ID
# List your workspaces anyt workspace list # Note your workspace ID (e.g., 1)
Step 3: Configure Claude Code
Add the MCP server to Claude Code's configuration file:
macOS/Linux: ~/.config/claude/mcp.json
Windows: %APPDATA%\Claude\mcp.json
{ "mcpServers": { "anytask": { "command": "anyt", "args": ["mcp", "serve"], "env": { "ANYTASK_API_URL": "http://0.0.0.0:8000", "ANYTASK_API_KEY": "anyt_agent_xxx", "ANYTASK_WORKSPACE_ID": "1" } } } }
Replace:
anyt_agent_xxx
with your actual agent API key1
with your workspace IDhttp://0.0.0.0:8000
with your backend URL if different
Step 4: Generate Configuration
Alternatively, use the CLI to generate the configuration:
anyt mcp config
This will output the configuration snippet with your current settings.
Step 5: Test Connection
Verify the MCP server can connect to AnyTask:
export ANYTASK_API_KEY=anyt_agent_xxx export ANYTASK_WORKSPACE_ID=1 anyt mcp test
Expected output:
Testing MCP server connection... ✓ API client initialized ✓ Connected to workspace: DEV ✓ Connected to project: default ✓ 8 tools available: - list_tasks - select_task - create_task - update_task - start_attempt - finish_attempt - add_artifact - get_board ✓ 1 resources + 3 templates available ✓ All tests passed!
Step 6: Restart Claude Code
Restart Claude Code to load the MCP configuration.
Available Tools
list_tasks
List tasks with optional filtering.
Arguments:
status
(optional): Filter by status (backlog, todo, inprogress, done, canceled)assignee_id
(optional): Filter by assignee IDlimit
(optional): Maximum number of tasks (default: 20)
Example:
List all tasks in progress
select_task
Select a task as the active task for the current workspace.
Arguments:
task_id
(required): Task identifier (e.g., "DEV-123")
Example:
Select task DEV-123
create_task
Create a new task.
Arguments:
title
(required): Task titledescription
(optional): Task descriptionpriority
(optional): Priority (-2 to 2)
Example:
Create a task "Implement user authentication" with priority 1
update_task
Update task fields.
Arguments:
task_id
(required): Task identifierversion
(required): Current version for optimistic lockingtitle
(optional): New titledescription
(optional): New descriptionstatus
(optional): New status
Example:
Update DEV-123 status to "done" with version 5
start_attempt
Start a work attempt on a task.
Arguments:
task_id
(required): Task identifiernotes
(optional): Notes about the attempt
Example:
Start an attempt on DEV-123
finish_attempt
Mark an attempt as finished.
Arguments:
attempt_id
(required): Attempt IDstatus
(required): Outcome (success, failed, aborted)failure_class
(optional): Failure classification if failedcost_tokens
(optional): Token costwall_clock_ms
(optional): Duration in millisecondsnotes
(optional): Notes about the outcome
Example:
Finish attempt 42 with status success
add_artifact
Upload an artifact for an attempt.
Arguments:
attempt_id
(required): Attempt IDtype
(required): Artifact type (diff, file, log, benchmark, screenshot)content
(required): Artifact contentmetadata
(optional): Additional metadata
Example:
Add a diff artifact to attempt 42 with the git diff output
get_board
Get Kanban board view of tasks organized by status.
Arguments: None
Example:
Show me the board
Available Resources
task://{task_id}/spec
Full task specification including title, description, status, and metadata.
Example URI: task://DEV-123/spec
task://{task_id}/deps
Task dependencies and dependents.
Example URI: task://DEV-123/deps
task://{task_id}/history
Event history and timeline for the task.
Example URI: task://DEV-123/history
workspace://current/active_task
Currently selected active task for the workspace.
Example URI: workspace://current/active_task
Usage Patterns
Working on a Task
Select task:
Select task DEV-123
Start attempt:
Start an attempt on DEV-123 with notes "Implementing authentication"
Work on implementation (Claude Code writes code)
Add artifacts:
Add a diff artifact to attempt 42 with this git diff: [paste diff]
Finish attempt:
Finish attempt 42 with status success
Creating and Organizing Tasks
Create task:
Create a task "Add rate limiting" with description "Implement rate limiting middleware" and priority 1
View board:
Show me the Kanban board
Update task:
Update DEV-124 status to "inprogress" with version 1
Exploring Task Context
Claude Code can automatically fetch task context using resources:
- Task specification provides full details
- Task dependencies show relationships
- Task history reveals past changes and attempts
Active Task Management
The MCP server maintains an active task in .anyt/active_task.json
:
{ "task_id": "DEV-123", "version": 5, "title": "Implement user authentication", "status": "inprogress", "workspace_id": 1, "last_sync": "2024-01-15T10:00:00Z" }
This file:
- Persists the active task across sessions
- Tracks version for optimistic locking
- Syncs with the backend on updates
Troubleshooting
"Error: No workspace configured"
Ensure ANYTASK_WORKSPACE_ID
is set in the MCP configuration.
"Error: API key is required"
Set ANYTASK_API_KEY
in the MCP configuration with a valid agent API key.
"Authentication failed"
Verify:
- API key is valid (starts with
anyt_agent_
) - API key has not been revoked
- Agent has access to the workspace
"Connection refused"
Ensure:
- AnyTask backend is running at the configured URL
- No firewall blocking the connection
- URL is correct (include http:// or https://)
Test the connection
export ANYTASK_API_KEY=your_key export ANYTASK_WORKSPACE_ID=1 anyt mcp test
Security Considerations
- API Key Storage: Store API keys securely in environment variables, not in code
- Workspace Isolation: Each agent API key is scoped to specific workspaces
- Permissions: Agent keys support granular permissions (read, write, execute)
- Audit Trail: All agent actions are logged in the event history
Advanced Configuration
Custom Workspace Directory
By default, the MCP server uses the current working directory for .anyt/
files. To use a different directory:
cd /path/to/your/project anyt mcp serve
Multiple Workspaces
To work with multiple workspaces, create separate MCP server configurations:
{ "mcpServers": { "anytask-dev": { "command": "anyt", "args": ["mcp", "serve"], "env": { "ANYTASK_WORKSPACE_ID": "1", "ANYTASK_API_KEY": "anyt_agent_dev_xxx" } }, "anytask-prod": { "command": "anyt", "args": ["mcp", "serve"], "env": { "ANYTASK_WORKSPACE_ID": "2", "ANYTASK_API_KEY": "anyt_agent_prod_xxx" } } } }
Next Steps
- Explore CLI documentation for more AnyTask features
- Review API documentation for endpoint details
- Check architecture overview for system design
Support
For issues or questions:
- Check the troubleshooting section
- Run
anyt mcp test
to diagnose connection issues - Review logs in Claude Code's output panel
- File an issue on GitHub with reproduction steps