Skip to content

Conversation

@christian-bromann
Copy link
Member

Adds support for Anthropic's MCP (Model Context Protocol) connector feature, which enables Claude to connect to remote MCP servers directly from the Messages API without implementing a separate MCP client.

Motivation

The MCP connector is a new Anthropic feature (beta: mcp-client-2025-11-20) that allows users to access tools from MCP servers through a simple API configuration. This eliminates the need to implement a separate MCP client while still benefiting from the MCP ecosystem of tools.

Usage

import { ChatAnthropic, tools } from "@langchain/anthropic";

const llm = new ChatAnthropic({
  model: "claude-sonnet-4-5-20250929",
});

// Basic usage - enable all tools from an MCP server
const response = await llm.invoke("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: [
    tools.mcpToolset_20251120({ serverName: "example-mcp" }),
  ],
});

// Allowlist pattern - enable only specific tools
const response2 = await llm.invoke("Search for events", {
  mcp_servers: [{
    type: "url",
    url: "https://calendar.example.com/sse",
    name: "google-calendar-mcp",
  }],
  tools: [
    tools.mcpToolset_20251120({
      serverName: "google-calendar-mcp",
      defaultConfig: { enabled: false },
      configs: {
        search_events: { enabled: true },
        create_event: { enabled: true },
      },
    }),
  ],
});

@changeset-bot
Copy link

changeset-bot bot commented Dec 3, 2025

🦋 Changeset detected

Latest commit: 7c13d9d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages
Name Type
@langchain/openai Minor
@langchain/anthropic Patch
@langchain/classic Patch
@langchain/community Patch
@langchain/deepseek Patch
@langchain/xai Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Member

@hntrl hntrl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not define this inside of the tool definition?

tools.mcpToolset_20251120({
  servers:     {
      type: "url",
      url: "https://example-server.modelcontextprotocol.io/sse",
      name: "example-mcp",
      authorization_token: "YOUR_TOKEN",
    },
}),

@christian-bromann
Copy link
Member Author

Why not define this inside of the tool definition?

Because the tool defines configuration for a single MCP server. If we would extend that to allow configuring all server and their configuration, the tool would have to return an array of tools which seems awkward. Plus, mcp_servers seems like a reasonable property to add since we also have other tool properties on their like container.

@christian-bromann christian-bromann force-pushed the cb/anthropic-bash-tool branch 2 times, most recently from e526c8d to f39cebc Compare December 8, 2025 23:14
@christian-bromann christian-bromann merged commit 7c13d9d into cb/anthropic-bash-tool Dec 9, 2025
29 of 30 checks passed
@christian-bromann christian-bromann deleted the cb/anthropic-mcp-toolset branch December 9, 2025 00:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants