Human-readable server name used in the ACP declaration.
Handles MCP requests addressed to this server.
OptionaladmitDecides whether a request to this server is served. The provider calls it
for every mcp/message request to the server, before handler. Without
it, every request reaches the handler.
Throw an McpSessionError, or call
McpAdmissionRequest.requireSession or
McpAdmissionRequest.rejectSession, which throw it, to reject the
request. The handler is then not called, and the caller gets an outer ACP
-32602 (Invalid params) with the error's message and
data: { serverId, sessionId } (sessionId only if the request has one).
Return, or resolve, to admit the request. The handler and its tools then
read the session from McpOperationContext.sessionId.
Rules can differ by request. A server whose tools are registered with the MCP SDK tells them apart by McpAdmissionRequest.toolName:
provider.registerServer(connection.agent, {
name: "project-tools",
handler: tools.handler,
admit: (request) => {
// `word_count` works on a session's files. `echo` and discovery do not.
if (request.toolName !== "word_count") return;
if (!openSessions.has(request.requireSession())) request.rejectSession();
},
});
It runs after the binding's own checks: the server is registered, the
request ID is not in use, the server is under maxActiveRequests, and the
inner request carries valid MCP metadata. A request whose metadata is
missing or unsupported gets its inner MCP error without reaching admit.
While admit runs, the request holds its request ID and counts toward
maxActiveRequests. Both are released when admit rejects it. If the
caller cancels the request or the registration is disposed while an
asynchronous admit is pending, the handler is not called and the
request ends as cancelled (-32800). McpAdmissionRequest.signal
aborts at that moment. A check that ignores it keeps running: the
-32800 answer, and the registration's dispose(), wait until the check
settles.
Any other error thrown from admit is a failure of the check, not a
rejection: the handler is not called, and the caller gets -33002 with
the message "MCP server admission check failed".
OptionalserverOpaque server ID. Defaults to a fresh random ID. An ID can be registered at most once per ACP connection, even after it is disposed.
OptionalmaxMaximum concurrently active requests for this server. Requests over the
limit fail with -33000. Defaults to 64.
Options for registering an MCP server on an ACP connection.