MCPcopy
hub / github.com/claude-code-best/claude-code / buildConnectedServer

Function buildConnectedServer

packages/mcp-client/src/connection.ts:510–539  ·  view source on GitHub ↗
(
  options: BuildConnectedServerOptions,
  logger: McpClientDependencies['logger'],
)

Source from the content-addressed store, hash-verified

508 * Truncates server instructions if they exceed MAX_MCP_DESCRIPTION_LENGTH.
509 */
510export function buildConnectedServer(
511 options: BuildConnectedServerOptions,
512 logger: McpClientDependencies['logger'],
513): ConnectedMCPServer {
514 const { name, client, config, cleanup } = options
515
516 const capabilities = client.getServerCapabilities() ?? {}
517 const serverVersion = client.getServerVersion()
518 const rawInstructions = client.getInstructions()
519
520 let instructions = rawInstructions
521 if (rawInstructions && rawInstructions.length > MAX_MCP_DESCRIPTION_LENGTH) {
522 instructions =
523 rawInstructions.slice(0, MAX_MCP_DESCRIPTION_LENGTH) + '… [truncated]'
524 logger.debug(
525 `[${name}] Server instructions truncated from ${rawInstructions.length} to ${MAX_MCP_DESCRIPTION_LENGTH} chars`,
526 )
527 }
528
529 return {
530 name,
531 client,
532 type: 'connected' as const,
533 capabilities,
534 serverInfo: serverVersion,
535 instructions,
536 config,
537 cleanup,
538 }
539}

Callers

nothing calls this directly

Calls 1

debugMethod · 0.65

Tested by

no test coverage detected