mcp-connector
agents-and-tools/mcp-connector
History
agents-and-tools/mcp-connector Changed · +2 / -2 lines
<Tabs> <Tab title="Gradle"> ```kotlin - implementation("com.anthropic:anthropic-java-mcp:2.57.0") + implementation("com.anthropic:anthropic-java-mcp:2.58.0") ``` </Tab>
<dependency> <groupId>com.anthropic</groupId> <artifactId>anthropic-java-mcp</artifactId> - <version>2.57.0</version> + <version>2.58.0</version> </dependency> ``` </Tab>
agents-and-tools/mcp-connector Changed · +1 / -2 lines
- Status: Beta - [Beta header](https://platform.claude.com/docs/en/api/beta-headers): `mcp-client-2025-11-20` - [ZDR](https://platform.claude.com/docs/en/manage-claude/api-and-data-retention): not eligible -- Platforms: Claude API (beta), Claude Platform on AWS (beta), Microsoft Foundry (beta) [1]; not available on Amazon Bedrock, Google Cloud -1. On [Microsoft Foundry](https://platform.claude.com/docs/en/build-with-claude/claude-in-microsoft-foundry), the MCP connector requires a [Hosted on Anthropic deployment](https://platform.claude.com/docs/en/build-with-claude/claude-in-microsoft-foundry#additional-features-not-supported-when-hosted-on-azure). +- Platforms: Claude API (beta), Claude Platform on AWS (beta), Microsoft Foundry (beta); not available on Amazon Bedrock, Google Cloud Claude's Model Context Protocol (MCP) connector feature enables you to connect to remote MCP servers directly from the Messages API without a separate MCP client.
agents-and-tools/mcp-connector Changed · +1 / -2 lines
``` ```php PHP - // The PHP SDK exposes the Files API under the beta namespace; field names can differ from other SDKs. // As a content block in a message $resource = $mcp->readResource('file:///path/to/doc.txt');
// As a file upload $fileResource = $mcp->readResource('file:///path/to/data.json'); - $file = $anthropic->beta->files->upload(file: BetaMcp::resourceToFile($fileResource)); + $file = $anthropic->files->upload(file: BetaMcp::resourceToFile($fileResource)); echo $file->id, "\n"; ```
agents-and-tools/mcp-connector Changed · +1 / -0 lines
``` ```php PHP + // The PHP SDK exposes the Files API under the beta namespace; field names can differ from other SDKs. // As a content block in a message $resource = $mcp->readResource('file:///path/to/doc.txt');
agents-and-tools/mcp-connector Changed · +8 / -8 lines
<Tabs> <Tab title="Gradle"> ```kotlin - implementation("com.anthropic:anthropic-java-mcp:2.53.0") + implementation("com.anthropic:anthropic-java-mcp:2.57.0") ``` </Tab>
<dependency> <groupId>com.anthropic</groupId> <artifactId>anthropic-java-mcp</artifactId> - <version>2.53.0</version> + <version>2.57.0</version> </dependency> ``` </Tab>
file_resource = await mcp_client.read_resource( uri="file:///path/to/data.json", ) - uploaded = await client.beta.files.upload( + uploaded = await client.files.upload( file=mcp_resource_to_file(file_resource), ) print(uploaded.id)
// As a file upload const fileResource = await mcpClient.readResource({ uri: "file:///path/to/data.json" }); - const uploaded = await anthropic.beta.files.upload({ file: mcpResourceToFile(fileResource) }); + const uploaded = await anthropic.files.upload({ file: mcpResourceToFile(fileResource) }); console.log(uploaded.id); ```
file.ContentType = new(mediaType); } - var uploaded = await anthropic.Beta.Files.Upload(new FileUploadParams { File = file }); + var uploaded = await anthropic.Files.Upload(new FileUploadParams { File = file }); Console.WriteLine(uploaded.ID); ```
if err != nil { log.Fatal(err) } - uploaded, err := client.Beta.Files.Upload(ctx, anthropic.BetaFileUploadParams{File: fileReader}) + uploaded, err := client.Files.Upload(ctx, anthropic.FileUploadParams{File: fileReader}) if err != nil { log.Fatal(err) }
fileField.contentType(resourceFile.mimeType()); } - var uploaded = anthropic.beta().files().upload(FileUploadParams.builder() + var uploaded = anthropic.files().upload(FileUploadParams.builder() .file(fileField.build()) .build());
# As a file upload file_resource = mcp_client.read_resource(uri: "file:///path/to/data.json") file = Anthropic::Mcp.resource_to_files(file_resource).first - uploaded_file = anthropic.beta.files.upload(file: file) + uploaded_file = anthropic.files.upload(file: file) puts uploaded_file.id ``` </CodeGroup>
agents-and-tools/mcp-connector First recorded · 1499 lines, first recorded
## Compatibility ## Key features ## When Claude uses MCP tools ## Limitations ## Using the MCP connector in the Messages API ### Basic example ## MCP server configuration ### Field descriptions ## MCP toolset configuration ### Basic structure ### Field descriptions ### Tool configuration options ### Configuration merging ## Common configuration patterns ### Enable all tools with default configuration ### Allowlist: enable only specific tools ### Denylist: disable specific tools ### Mixed: allowlist with per-tool configuration ## Validation rules ## Response content types ### MCP tool use block ### MCP tool result block ## Multiple MCP servers ## Authentication ### Obtaining an access token for testing ### Using the access token ## Client-side MCP helpers ### Installation ### Available helpers ### Use MCP tools ### Use MCP prompts ### Use MCP resources ### Error handling ## Batch requests ## Data retention ## Migration guide ### Key changes ### Migration steps ### Common migration patterns ## Deprecated version: mcp-client-2025-04-04 ### Deprecated field descriptions
The first capture of this source. The page was already there, and this is what it said.
---
title: MCP connector
url: https://platform.claude.com/docs/en/agents-and-tools/mcp-connector
description: Connect to remote MCP servers directly from the Messages API without an MCP client, and allowlist, denylist, or configure individual tools.
---
## Compatibility
- Status: Beta
- [Beta header](https://platform.claude.com/docs/en/api/beta-headers): `mcp-client-2025-11-20`
- [ZDR](https://platform.claude.com/docs/en/manage-claude/api-and-data-retention): not eligible
- Platforms: Claude API (beta), Claude Platform on AWS (beta), Microsoft Foundry (beta) [1]; not available on Amazon Bedrock, Google Cloud
1. On [Microsoft Foundry](https://platform.claude.com/docs/en/build-with-claude/claude-in-microsoft-foundry), the MCP connector requires a [Hosted on Anthropic deployment](https://platform.claude.com/docs/en/build-with-claude/claude-in-microsoft-foundry#additional-features-not-supported-when-hosted-on-azure).
Claude's Model Context Protocol (MCP) connector feature enables you to connect to remote MCP servers directly from the Messages API without a separate MCP client.
<Note>
The previous version of this feature (`mcp-client-2025-04-04`) is deprecated. See [Deprecated version: mcp-client-2025-04-04](https://platform.claude.com/docs/en/agents-and-tools/mcp-connector#deprecated-version-mcp-client-2025-04-04).
</Note>
## Key features
* **Direct API integration:** Connect to MCP servers without implementing an MCP client
* **Tool calling support:** Access MCP tools through the Messages API
* **Flexible tool configuration:** Enable all tools, allowlist specific tools, or denylist unwanted tools
* **Per-tool configuration:** Configure individual tools with custom settings
* **OAuth authentication:** Support for OAuth Bearer tokens for authenticated servers
* **Multiple servers:** Connect to multiple MCP servers in a single request
## When Claude uses MCP tools
Once an MCP server is connected, Claude calls its tools when the user's request maps to a tool's described capability, either explicitly ("search Jira for open bugs") or implicitly ("what's blocking the release?" with a Jira server attached).
Claude does **not** call an MCP tool for general knowledge questions about a connected service. Asking "how do Notion databases work?" with a Notion server attached is answered directly; asking "what's in my Projects database?" triggers the tool.
You can steer how readily Claude calls MCP tools through your system prompt. See [When Claude uses tools](https://platform.claude.com/docs/en/agents-and-tools/tool-use/overview#when-claude-uses-tools) for general guidance and example phrasings.
## Limitations
* Of the feature set of the [MCP specification](https://modelcontextprotocol.io/introduction#explore-mcp), only [tool calls](https://modelcontextprotocol.io/docs/concepts/tools) are currently supported.
* The server must be publicly exposed through HTTP (supports both Streamable HTTP and SSE transports). Local STDIO servers cannot be connected directly.
## Using the MCP connector in the Messages API
The MCP connector uses two components:
1. **MCP server definition** (`mcp_servers` array): Defines server connection details (URL, authentication)
2. **MCP toolset** (`tools` array): Configures which tools to enable and how to configure them
### Basic example
This example enables all tools from an MCP server with default configuration:
<CodeGroup>
```bash cURL
curl https://api.anthropic.com/v1/messages \
-H "Content-Type: application/json" \
-H "X-API-Key: $ANTHROPIC_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "anthropic-beta: mcp-client-2025-11-20" \
-d '{
"model": "claude-opus-5",
"max_tokens": 1000,
"messages": [{"role": "user", "content": "What tools do you have available?"}],
"mcp_servers": [
{
"type": "url",
"url": "https://example-server.modelcontextprotocol.io/sse",
"name": "example-mcp",
"authorization_token": "YOUR_TOKEN"
}
],
"tools": [
{
"type": "mcp_toolset",
"mcp_server_name": "example-mcp"
}
]
}'
```
```bash CLI
ant beta:messages create --beta mcp-client-2025-11-20 <<'YAML'
model: claude-opus-5
max_tokens: 1000
messages:
- role: user
content: What tools do you have available?
mcp_servers:
- type: url
url: https://example-server.modelcontextprotocol.io/sse
name: example-mcp
authorization_token: YOUR_TOKEN
tools:
- type: mcp_toolset
mcp_server_name: example-mcp
YAML
```
```python Python
client = anthropic.Anthropic()
response = client.beta.messages.create(
model="claude-opus-5",
max_tokens=1000,
messages=[{"role": "user", "content": "What tools do you have available?"}],
mcp_servers=[
{
"type": "url",
"url": "https://example-server.modelcontextprotocol.io/sse",
"name": "example-mcp",
"authorization_token": "YOUR_TOKEN",
}
],
tools=[{"type": "mcp_toolset", "mcp_server_name": "example-mcp"}],
betas=["mcp-client-2025-11-20"],
)
print(response)
```
```typescript TypeScript
const anthropic = new Anthropic();
const response = await anthropic.beta.messages.create({
model: "claude-opus-5",
max_tokens: 1000,
messages: [
{
role: "user",
content: "What tools do you have available?"
}
],
mcp_servers: [
{
type: "url",
url: "https://example-server.modelcontextprotocol.io/sse",
name: "example-mcp",
authorization_token: "YOUR_TOKEN"
}
],
tools: [
{
type: "mcp_toolset",
mcp_server_name: "example-mcp"
}
],
betas: ["mcp-client-2025-11-20"]
});
console.log(response);
```
```csharp C#
AnthropicClient client = new();
var parameters = new MessageCreateParams
{
Model = Model.ClaudeOpus5,
MaxTokens = 1000,
Messages = new List<BetaMessageParam>
{
new() { Role = Role.User, Content = "What tools do you have available?" }
},
McpServers = new List<BetaRequestMcpServerUrlDefinition>
{
new()
{
Url = "https://example-server.modelcontextprotocol.io/sse",
Name = "example-mcp",
AuthorizationToken = "YOUR_TOKEN"
}
},
Tools = new List<BetaToolUnion>
{
new BetaMcpToolset("example-mcp")
},
Betas = [AnthropicBeta.McpClient2025_11_20]
};
var message = await client.Beta.Messages.Create(parameters);
Console.WriteLine(message);
```
```go Go
client := anthropic.NewClient()
response, err := client.Beta.Messages.New(context.TODO(), anthropic.BetaMessageNewParams{
Model: anthropic.ModelClaudeOpus5,
MaxTokens: 1000,
Messages: []anthropic.BetaMessageParam{
anthropic.NewBetaUserMessage(anthropic.NewBetaTextBlock("What tools do you have available?")),
},
MCPServers: []anthropic.BetaRequestMCPServerURLDefinitionParam{
{
URL: "https://example-server.modelcontextprotocol.io/sse",
Name: "example-mcp",
AuthorizationToken: anthropic.String("YOUR_TOKEN"),
},
},
Tools: []anthropic.BetaToolUnionParam{
{OfMCPToolset: &anthropic.BetaMCPToolsetParam{
MCPServerName: "example-mcp",
}},
},
Betas: []anthropic.AnthropicBeta{
anthropic.AnthropicBetaMCPClient2025_11_20,
},
})
if err != nil {
log.Fatal(err)
}
fmt.Println(response)
```
```java Java
import com.anthropic.models.beta.messages.BetaMcpToolset;
// ...
import com.anthropic.models.beta.messages.BetaRequestMcpServerUrlDefinition;
// ...
void main() {
AnthropicClient client = AnthropicOkHttpClient.fromEnv();
MessageCreateParams params = MessageCreateParams.builder()
.model(Model.CLAUDE_OPUS_5)
.maxTokens(1000L)
.addUserMessage("What tools do you have available?")
.addMcpServer(BetaRequestMcpServerUrlDefinition.builder()
.url("https://example-server.modelcontextprotocol.io/sse")
.name("example-mcp")
.authorizationToken("YOUR_TOKEN")
.build())
.addTool(BetaMcpToolset.builder()
.mcpServerName("example-mcp")
.build())
.addBeta(AnthropicBeta.MCP_CLIENT_2025_11_20)
.build();
BetaMessage response = client.beta().messages().create(params);
IO.println(response);
}
```
```php PHP
$client = new Client();
$message = $client->beta->messages->create(
maxTokens: 1000,
messages: [
['role' => 'user', 'content' => 'What tools do you have available?']
],
model: 'claude-opus-5',
mcpServers: [
[
'type' => 'url',
'url' => 'https://example-server.modelcontextprotocol.io/sse',
'name' => 'example-mcp',
'authorization_token' => 'YOUR_TOKEN',
],
],
tools: [
[
'type' => 'mcp_toolset',
'mcp_server_name' => 'example-mcp',
],
],
betas: ['mcp-client-2025-11-20'],
);
echo $message;
```
```ruby Ruby
client = Anthropic::Client.new
response = client.beta.messages.create(
model: "claude-opus-5",
max_tokens: 1000,
messages: [
{ role: "user", content: "What tools do you have available?" }
],
mcp_servers: [
{
type: "url",
url: "https://example-server.modelcontextprotocol.io/sse",
name: "example-mcp",
authorization_token: "YOUR_TOKEN"
}
],
tools: [
{
type: "mcp_toolset",
mcp_server_name: "example-mcp"
}
],
betas: ["mcp-client-2025-11-20"]
)
puts response
```
Cut at 300 lines.