Repository navigation
feat(mcp): move to @langchain/mcp-adapters v2 on MCP SDK v2 - #57
Merged
Merged
Conversation
Upgrade the MCP adapter to 2.x, built on @modelcontextprotocol/client, and drop @modelcontextprotocol/sdk (v1) everywhere, OAuth included. - Connector: MCPAdapter + listTools(). Tools keep the adapter's default `server_tool` names; the disclosure package builds the same names via prefixedToolName(), so the connector renames nothing. - Elicitation is off per server: its interrupt is one the approval flow cannot answer, so the thread would hang. - The Connections probe opens its session through the connector, which is now the only file using the adapter. - OAuth: the check route delegates to the SDK's auth(), which picks the scope from the server instead of a hardcoded "read write" (Keycloak rejected registration with it), and adds the RFC 8707 resource. The callback forwards all params so the SDK can check `iss` (RFC 9207). The provider implements invalidateCredentials(). - Saving an HTTP server probes it and records its OAuth status, so the Connect button appears; a 401 at connect time records REQUIRED or EXPIRED and returns auth_required. - Bump @langchain/core and @langchain/langgraph to the adapter's peers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Moves Cameron's MCP client to
@langchain/mcp-adapters2.x, which is built on the MCP TypeScript SDK v2 (@modelcontextprotocol/client).@modelcontextprotocol/sdk(v1) is removed, along with its pnpm override.Adapter
connector.tsusesMCPAdapter/listTools()and is now the only file using the adapter: the Connections page's tool lister opens its session through it too.{server}_{tool}by default. The disclosure package now builds the same names (prefixedToolName()inpolicy.ts), so the tool the model is shown and the tool that runs carry one name and the connector renames nothing.getTool/resolveTooltake the name as the model called it. Server names containing_are already disambiguated bycreateToolServerIndex.elicitation: false). v2 raises it as a LangGraph interrupt, which the approval flow can't answer, so the thread would hang. Listed as deferred indocs/MCP_DISCLOSURE.md.as any). Stdioargsis now always sent.@langchain/coreand@langchain/langgraphare bumped to the adapter's peer ranges, in the disclosure package too, so only one copy of core is installed.OAuth
Found while live-testing against a local Keycloak-backed MCP server:
scope: "read write". The check route now delegates to the SDK'sauth(), which takes the scope from the server's challenge or resource metadata, registers the client, and builds the authorization URL with PKCE and the RFC 8707resourceparameter.finishAuth, so the SDK can checkiss(RFC 9207).REQUIRED/EXPIRED/UNKNOWN. Saving an HTTP server (create, or a URL change) now probes it and records the status. A 401 at connect time (isAuthFailure, which walks the error's cause chain) recordsREQUIRED, orEXPIREDif the server was connected, and returnsauth_required.invalidateCredentials()(newclearOAuthCredentialsrepository function).Test plan
tsc --noEmit,pnpm typecheck:eval,pnpm test(455 passing, 3 new forisAuthFailure),pnpm buildserver_toolnamesserver__toolnames dropped out cleanly and were reloaded; result confirmed by a direct read through the connectorCONNECTED, refresh token, scopeoffline_access mcp:tools) towhoami/list_notes/create_note/get_notethrough the agent, confirmed directlyEXPIREDpath (unit-tested only)Notes
run_sqlcan currently read themcp_servertable. Both are being fixed separately: a database role that limitsrun_sqlto the finance tables, and encryption at rest.server__toolnames no longer match. A newload_toolscall loads them again.🤖 Generated with Claude Code