inspector/core/mcp/config.ts
Cliff Hall 373f346e5f
Some checks failed
Run install, format, lint, build, and test on every push / build (push) Has been cancelled
Run install, format, lint, build, and test on every push / publish (push) Has been cancelled
Run install, format, lint, build, and test on every push / publish-github-container-registry (push) Has been cancelled
chore: close quality-gate coverage gaps (#1689) (#1766)
Closes #1689. Typecheck cli/tui src, add a core/ format+lint gate, and gate core/json + core/client coverage. See PR #1766 for the full review history.
2026-07-24 17:20:12 -04:00

40 lines
1.2 KiB
TypeScript

import type { MCPServerConfig, ServerType } from "./types.js";
/**
* Returns the transport type for an MCP server configuration.
* If type is omitted, defaults to "stdio". Throws if type is invalid.
*/
export function getServerType(config: MCPServerConfig): ServerType {
if (!("type" in config) || config.type === undefined) {
return "stdio";
}
const type = config.type;
if (type === "stdio") {
return "stdio";
}
if (type === "sse") {
return "sse";
}
if (type === "streamable-http") {
return "streamable-http";
}
throw new Error(
`Invalid server type: ${type}. Valid types are: stdio, sse, streamable-http`,
);
}
/** OAuth and enterprise-managed auth apply only to remote HTTP-based transports. */
export function isOAuthCapableServerType(type: ServerType): boolean {
return type === "sse" || type === "streamable-http";
}
/**
* MCP server URL used as the OAuth storage key (includes path, for discovery).
* Undefined for stdio transports.
*/
export function getOAuthServerUrl(config: MCPServerConfig): string | undefined {
if (config.type === "sse" || config.type === "streamable-http") {
return config.url;
}
return undefined;
}