Open History to see the last commit
1import type { MCPServerOptions } from './create-server'
2
3// Keeps the options of each server for `directMCPClient`.
4// This module imports nothing at runtime, so the client entry point can read
5// the options without loading the server SDK.
6const serverOptionsByServer = new WeakMap<object, MCPServerOptions>()
7
8/** Internal. Records the options that `server` was created with. */
9export function rememberServerOptions(
10 server: object,
11 options: MCPServerOptions,
12) {
13 serverOptionsByServer.set(server, options)
14}
15
16/** Internal. Returns the options that `server` was created with. */
17export function optionsOfServer(server: object) {
18 return serverOptionsByServer.get(server)
19}
20
21// A stdio process serves one client, so spec 2025 sessions cost nothing.
22const stdioServers = new WeakSet<object>()
23
24/** Internal. Records that `serveMCPStdio` serves `server`. */
25export function markServedOverStdio(server: object) {
26 stdioServers.add(server)
27}
28
29/** Internal. True when `serveMCPStdio` serves `server`. */
30export function isServedOverStdio(server: object) {
31 return stdioServers.has(server)
32}