# Configure MCP Tool Servers

Connect external MCP servers (GitHub, Notion, Slack, Google Workspace, custom tools) so agents can call them during their ReAct loop.

**What to connect:** $ARGUMENTS

---

Read `skills/configure-mcp/SKILL.md` fully before writing any code.

## Step 1 — Identify what the user needs

From $ARGUMENTS, determine:
- Which MCP server(s) to connect (GitHub, Notion, Slack, Google, custom, etc.)
- Transport type (SSE for remote, stdio for local)
- Which agent(s) will use these tools

If not specified, ask:
```
To configure MCP tools I need to know:

1. **Which MCP server?** (e.g. GitHub, Notion, Slack, Google Workspace, a custom URL)
2. **Which agent(s) should use it?** (or all of them?)
3. **Do you have the server URL and auth token?**
```

## Step 2 — Install dependency

Check if `arccrew[mcp]` is in `requirements.txt`. If not, add it:

```
arccrew[mcp]
```

Run: `pip install "arccrew[mcp]"`

## Step 3 — Add the server to arccrew.json

Open `arccrew.json` and add the server under `mcpServers`. Use `${ENV_VAR}` for API keys:

```json
{
  "mcpServers": {
    "github": {
      "transport": "sse",
      "url": "https://api.githubcopilot.com/mcp/",
      "headers": { "Authorization": "Bearer ${GITHUB_TOKEN}" }
    }
  }
}
```

Remove any `_example_*` placeholder keys that are already in the file.

## Step 4 — Add API keys to .env.example and .env

For each server that needs auth, add the key to `.env.example`:
```bash
# MCP Tool Servers
GITHUB_TOKEN=
```

Remind the user to set the actual value in `.env`.

## Step 5 — Update the agent

In the target agent's `execute()`, load MCP tools from `arccrew.json`:

```python
from arccrew.tools import get_mcp_tools, get_research_tools

# All configured servers
tools = get_research_tools() + await get_mcp_tools()

# Or specific servers only
tools = get_research_tools() + await get_mcp_tools(["github"])

result = await self.run_react(task=task, tools=tools)
```

## Step 6 — Update the agent prompt

MCP tools must be explicitly named in the prompt or the LLM will ignore them.
Open `prompts/{agent}.md` and add a section listing each MCP tool with its prefix:

```markdown
## Available Tools

- `github_search_repositories` — search GitHub repos by topic or keyword
- `github_get_file_contents` — read a specific file from a repo
```

## Step 7 — Show the user

```
MCP tools configured:

  Server:    {server_name} ({transport})
  Config:    arccrew.json → mcpServers.{server_name}
  Auth key:  {KEY_NAME} (set in .env)

All agents can now use:
  tools = await get_mcp_tools()          # all servers
  tools = await get_mcp_tools(["{server_name}"])  # this server only

Install if not done:
  pip install "arccrew[mcp]"
```
