# <Mcp />

Grant a provider-native or explicitly configured MCP server to one Agent session.
Canonical: https://agent-markup-language.com/docs/reference/primitives/mcp/
Documentation index: https://agent-markup-language.com/docs/
Complete documentation: https://agent-markup-language.com/docs/llms.txt

`<Mcp />` grants one Model Context Protocol server to its nearest containing [`<Agent />`](https://agent-markup-language.com/docs/reference/primitives/agent/). Select exactly one form: a provider-native server name or a transport descriptor returned by [`defineMcpServer()`](https://agent-markup-language.com/docs/reference/mcp-server/).

```tsx
import { Agent, AmlRuntime, defineMcpServer, Mcp } from "@aml-jsx/sdk"
import { DeterministicAgentProvider } from "@aml-jsx/sdk/testing"

const documentation = defineMcpServer({
  name: "documentation",
  transport: {
    type: "streamable-http",
    url: "https://mcp.example.com/docs",
  },
})

const runtime = new AmlRuntime({ agentProvider: new DeterministicAgentProvider() })
await runtime.evaluate(
  <Agent>
    <Mcp use={documentation} />
    Find the relevant API contract.
  </Agent>
)
```

The deterministic provider verifies AML's descriptor composition without opening the example URL. A live MCP check requires a provider that supports the selected transport and a reachable server; use the provider guides and cookbook below for that path.

For a provider-native server configured outside AML, use `<Mcp name="server-name" />` instead.

## Props

| Form       | Required prop       | Meaning                                                                                                              |
| ---------- | ------------------- | -------------------------------------------------------------------------------------------------------------------- |
| Named      | `name: string`      | Ask the Agent provider for a provider-native server with that normalized name.                                       |
| Configured | `use: AmlMcpServer` | Attach the exact stdio or Streamable HTTP descriptor returned by [`defineMcpServer()`](https://agent-markup-language.com/docs/reference/mcp-server/). |

`<Mcp />` accepts no children. Names must be unique inside one `<Agent />` and may be restricted by `AmlRuntime({ allowedMcpServers })`.

## Ownership and compatibility

- AML captures and validates the descriptor; the selected Agent provider owns connection and session lifecycle.
- A stdio server runs where that provider launches it. Do not assume this is the AML host or the active Sandbox without checking the provider guide.
- Streamable HTTP headers are privileged deployment configuration. Avoid persisting secrets in workflow source, traces, or Workspace files.
- Provider MCP support differs. Check [Codex](https://agent-markup-language.com/docs/providers/agents/codex/), [GitHub Copilot](https://agent-markup-language.com/docs/providers/agents/copilot/), [OpenCode](https://agent-markup-language.com/docs/providers/agents/opencode/), or [Pi](https://agent-markup-language.com/docs/providers/agents/pi/) before choosing a form.

See the [`defineMcpServer()` reference](https://agent-markup-language.com/docs/reference/mcp-server/), [Connect an MCP server](https://agent-markup-language.com/docs/cookbook/mcp/), and [Tool or MCP?](https://agent-markup-language.com/docs/cookbook/tool-or-mcp/) for complete examples and trade-offs.
