Throws -32602 (Invalid params) for the first MCP server the agent cannot
accept: one whose name repeats an earlier server's, whose transport the
agent did not advertise in session.mcp, or whose stdio command is not an
absolute path.
Call it from session/new, session/resume, or session/fork handlers with
the capabilities.session.mcp value the agent sent in its initialize
response. Each server name must be unique within the list; a duplicate is
rejected with error data { name }. A server is accepted only when its
type is a transport key in that object with a non-null value, for example
stdio with { stdio: {} }. Everything else is rejected, including v1's
sse, unknown types, and custom _-prefixed types; agents that support a
custom transport should handle those servers before calling this. The error
data for a transport is { type } with the rejected server's transport.
The command of a stdio server must be an absolute path. A relative one,
such as npx or ./server, is rejected with error data
{ name, command }. This function does not know which machine the agent
runs on, so it accepts a path that is absolute in POSIX or in Windows
syntax: /usr/bin/server, C:\tools\server.exe, or
\\host\share\server.exe. An agent that needs the native syntax of its own
machine, for example to reject C:\tools\server.exe on Linux, checks that
itself.
Throws
-32602(Invalid params) for the first MCP server the agent cannot accept: one whosenamerepeats an earlier server's, whose transport the agent did not advertise insession.mcp, or whose stdiocommandis not an absolute path.Call it from
session/new,session/resume, orsession/forkhandlers with thecapabilities.session.mcpvalue the agent sent in itsinitializeresponse. Each servernamemust be unique within the list; a duplicate is rejected with error data{ name }. A server is accepted only when itstypeis a transport key in that object with a non-null value, for examplestdiowith{ stdio: {} }. Everything else is rejected, including v1'ssse, unknown types, and custom_-prefixed types; agents that support a custom transport should handle those servers before calling this. The error data for a transport is{ type }with the rejected server's transport.The
commandof a stdio server must be an absolute path. A relative one, such asnpxor./server, is rejected with error data{ name, command }. This function does not know which machine the agent runs on, so it accepts a path that is absolute in POSIX or in Windows syntax:/usr/bin/server,C:\tools\server.exe, or\\host\share\server.exe. An agent that needs the native syntax of its own machine, for example to rejectC:\tools\server.exeon Linux, checks that itself.