

# Connect an MCP client

Most clients connect through `mcp-proxy-for-aws`, a local proxy that signs each request with your AWS credentials.

## Prerequisites
<a name="connect-an-mcp-client-prerequisites"></a>
+  AWS credentials on your computer (from `aws configure`, an IAM Identity Center profile, or environment variables).
+  `uv` (which provides `uvx`) with Python 3.11 or later.
+ The permissions in [Authentication and identity for MCP](authentication-and-identity-for-mcp.md).

## To connect a client that reads an mcpServers file
<a name="to-connect-a-client-that-reads-an-mcpservers-file"></a>

Add the following server (the **Integration** tab shows it prefilled). Set `AWS_PROFILE` to the profile that holds your credentials, or remove it to use the default credential chain. The two timeout flags give the agentic tools their full time budgets.

```json
{
  "mcpServers": {
    "agent-context": {
      "command": "uvx",
      "args": [
        "mcp-proxy-for-aws-cli@latest",
        "https://context-mcp.us-east-1.api.aws/mcp",
        "--service", "context-mcp",
        "--region", "us-east-1",
        "--read-timeout", "310",
        "--tool-timeout", "360"
      ],
      "env": { "AWS_PROFILE": "default", "AWS_REGION": "us-east-1" }
    }
  }
}
```

This works for Claude Desktop, Cursor, Amazon Q Developer, and Kiro (`~/.kiro/settings/mcp.json`).

## To connect Claude Code
<a name="to-connect-claude-code"></a>

```bash
claude mcp add agent-context --scope user \
  -e AWS_PROFILE=default -e AWS_REGION=us-east-1 \
  -- uvx mcp-proxy-for-aws-cli@latest https://context-mcp.us-east-1.api.aws/mcp \
     --service context-mcp --region us-east-1 --read-timeout 310 --tool-timeout 360
```

Run `claude mcp list` and confirm the server shows **Connected**. Every tool call must name the Agent context in `agentContextId`. Put the ID in the agent’s instructions (for Claude Code, in `CLAUDE.md`) so the model passes it without being asked.

## To connect with identity provider sign-in
<a name="to-connect-with-identity-provider-sign-in"></a>

If your Agent context has identity provider sign-in configured, add the server as a remote HTTP server. Use the **MCP server URL** from the **Integration** tab. The first connection opens a browser to your identity provider.

```json
{ "mcpServers": { "agent-context": { "type": "http", "url": "MCP server URL from the Integration tab" } } }
```

## To connect from code
<a name="to-connect-from-code"></a>

Use the `mcp-proxy-for-aws` Python library with the official `mcp` SDK.

```python
import asyncio
from mcp import ClientSession
from mcp_proxy_for_aws.client import aws_iam_streamablehttp_client

async def main():
    client = aws_iam_streamablehttp_client(
        endpoint="https://context-mcp.us-east-1.api.aws/mcp",
        aws_region="us-east-1",
        aws_service="context-mcp",
    )
    async with client as (read, write):
        async with ClientSession(read, write) as session:
            await session.initialize()
            result = await session.call_tool(
                "context___SearchAgentContext",
                {"agentContextId": "ac-1234567890abcdef", "query": "customer orders", "searchType": "AUTO"},
            )
            print(result.content[0].text)

asyncio.run(main())
```

To verify a connection, ask your agent to search the Agent context. Missing permissions appear on the first tool call, not when the client connects.