@@ -525,25 +525,21 @@ Available commands:
525525- Restart the session: ` { restart: true } `
526526
527527``` typescript
528- import {
529- ChatAnthropic ,
530- tools ,
531- type Bash20250124Command ,
532- } from " @langchain/anthropic" ;
528+ import { ChatAnthropic , tools } from " @langchain/anthropic" ;
533529import { execSync } from " child_process" ;
534530
535531const llm = new ChatAnthropic ({
536532 model: " claude-sonnet-4-5-20250929" ,
537533});
538534
539535const bash = tools .bash_20250124 ({
540- execute : async (args : Bash20250124Command ) => {
536+ execute : async (args ) => {
541537 if (args .restart ) {
542538 // Reset session state
543539 return " Bash session restarted" ;
544540 }
545541 try {
546- const output = execSync (args .command ! , {
542+ const output = execSync (args .command , {
547543 encoding: " utf-8" ,
548544 timeout: 30000 ,
549545 });
@@ -567,6 +563,143 @@ console.log(response.tool_calls?.[0].args.command); // "ls -la *.py"
567563
568564For more information, see [ Anthropic's Bash Tool documentation] ( https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/bash-tool ) .
569565
566+ ### MCP Toolset
567+
568+ The MCP toolset (` mcpToolset_20251120 ` ) enables Claude to connect to remote MCP (Model Context Protocol) servers directly from the Messages API without implementing a separate MCP client. This allows Claude to use tools provided by MCP servers.
569+
570+ Key features:
571+
572+ - ** Direct API integration** - Connect to MCP servers without implementing an MCP client
573+ - ** Tool calling support** - Access MCP tools through the Messages API
574+ - ** Flexible tool configuration** - Enable all tools, allowlist specific tools, or denylist unwanted tools
575+ - ** Per-tool configuration** - Configure individual tools with custom settings
576+ - ** OAuth authentication** - Support for OAuth Bearer tokens for authenticated servers
577+ - ** Multiple servers** - Connect to multiple MCP servers in a single request
578+
579+ ``` typescript
580+ import { ChatAnthropic , tools } from " @langchain/anthropic" ;
581+
582+ const llm = new ChatAnthropic ({
583+ model: " claude-sonnet-4-5-20250929" ,
584+ });
585+
586+ // Basic usage - enable all tools from an MCP server
587+ const response = await llm .invoke (" What tools do you have available?" , {
588+ mcp_servers: [
589+ {
590+ type: " url" ,
591+ url: " https://example-server.modelcontextprotocol.io/sse" ,
592+ name: " example-mcp" ,
593+ authorization_token: " YOUR_TOKEN" ,
594+ },
595+ ],
596+ tools: [tools .mcpToolset_20251120 ({ serverName: " example-mcp" })],
597+ });
598+ ```
599+
600+ ** Allowlist pattern** - Enable only specific tools:
601+
602+ ``` typescript
603+ const response = await llm .invoke (" Search for events" , {
604+ mcp_servers: [
605+ {
606+ type: " url" ,
607+ url: " https://calendar.example.com/sse" ,
608+ name: " google-calendar-mcp" ,
609+ authorization_token: " YOUR_TOKEN" ,
610+ },
611+ ],
612+ tools: [
613+ tools .mcpToolset_20251120 ({
614+ serverName: " google-calendar-mcp" ,
615+ // Disable all tools by default
616+ defaultConfig: { enabled: false },
617+ // Explicitly enable only these tools
618+ configs: {
619+ search_events: { enabled: true },
620+ create_event: { enabled: true },
621+ },
622+ }),
623+ ],
624+ });
625+ ```
626+
627+ ** Denylist pattern** - Disable specific tools:
628+
629+ ``` typescript
630+ const response = await llm .invoke (" List my events" , {
631+ mcp_servers: [
632+ {
633+ type: " url" ,
634+ url: " https://calendar.example.com/sse" ,
635+ name: " google-calendar-mcp" ,
636+ authorization_token: " YOUR_TOKEN" ,
637+ },
638+ ],
639+ tools: [
640+ tools .mcpToolset_20251120 ({
641+ serverName: " google-calendar-mcp" ,
642+ // All tools enabled by default, just disable dangerous ones
643+ configs: {
644+ delete_all_events: { enabled: false },
645+ share_calendar_publicly: { enabled: false },
646+ },
647+ }),
648+ ],
649+ });
650+ ```
651+
652+ ** Multiple MCP servers** :
653+
654+ ``` typescript
655+ const response = await llm .invoke (" Use tools from both servers" , {
656+ mcp_servers: [
657+ {
658+ type: " url" ,
659+ url: " https://mcp.example1.com/sse" ,
660+ name: " mcp-server-1" ,
661+ authorization_token: " TOKEN1" ,
662+ },
663+ {
664+ type: " url" ,
665+ url: " https://mcp.example2.com/sse" ,
666+ name: " mcp-server-2" ,
667+ authorization_token: " TOKEN2" ,
668+ },
669+ ],
670+ tools: [
671+ tools .mcpToolset_20251120 ({ serverName: " mcp-server-1" }),
672+ tools .mcpToolset_20251120 ({
673+ serverName: " mcp-server-2" ,
674+ defaultConfig: { deferLoading: true },
675+ }),
676+ ],
677+ });
678+ ```
679+
680+ ** With Tool Search** - Use deferred loading for on-demand tool discovery:
681+
682+ ``` typescript
683+ const response = await llm .invoke (" Find and use the right tool" , {
684+ mcp_servers: [
685+ {
686+ type: " url" ,
687+ url: " https://example.com/sse" ,
688+ name: " example-mcp" ,
689+ },
690+ ],
691+ tools: [
692+ tools .toolSearchRegex_20251119 (),
693+ tools .mcpToolset_20251120 ({
694+ serverName: " example-mcp" ,
695+ defaultConfig: { deferLoading: true },
696+ }),
697+ ],
698+ });
699+ ```
700+
701+ For more information, see [ Anthropic's MCP Connector documentation] ( https://docs.anthropic.com/en/docs/agents-and-tools/mcp-connector ) .
702+
570703## Development
571704
572705To develop the Anthropic package, you'll need to follow these instructions:
0 commit comments