# Configure MCP Tool Servers

Connect external MCP servers (GitHub, Notion, Slack, 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, 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, a custom server 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 `langchain-mcp-adapters` is in `requirements.txt`. If not, add it:

```
arccrew[mcp]
```

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

For each MCP 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 4 — Update the agent

In the target agent file, add `get_mcp_tools` and define the server config as a module-level constant:

```python
import os
from arccrew.tools import get_mcp_tools

GITHUB_MCP = {
    "transport": "sse",
    "url": "https://api.githubcopilot.com/mcp/",
    "headers": {"Authorization": f"Bearer {os.getenv('GITHUB_TOKEN')}"},
}
```

In `execute()`, fetch tools and pass to `run_react()`:

```python
tools = get_research_tools() + await get_mcp_tools({"github": GITHUB_MCP})
result = await self.run_react(task=task, tools=tools)
```

## Step 5 — 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:

```markdown
## Available Tools

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

Use the exact tool names as reported by the MCP server
(with prefix if `prefix_tool_names=True`, e.g. `github_search_repositories`).

## Step 6 — Show the user

```
MCP tools configured for {agent_name}:

  Server:    {server_name} ({transport})
  Tools:     {tool_names or "listed in prompt"}
  Auth key:  {KEY_NAME} (set in .env)

Install:
  pip install "arccrew[mcp]"

Then run:
  arccrew serve
  # Your agent can now call {server_name} tools during the ReAct loop
```
