mcp-server.ts

Overview

The mcp-server.ts file defines core type-safe structures for representing and categorizing MCP (likely "Media Control Protocol" or similar) server configurations within an application. It primarily provides an enumeration for supported server types and interfaces describing the shape of server-related data objects, including server metadata, connection details, and optional configuration variables.

This file serves as a foundational data contract layer, enabling consistent handling, validation, and communication of MCP server information across different system components.


Exports and Types

Enum: McpServerType

Defines the supported server types for MCP servers.

export enum McpServerType {
    Sse = 'sse',
    StreamableHttp = 'streamable-http',
}

Usage Example:

const serverType: McpServerType = McpServerType.Sse;
console.log(serverType); // Output: 'sse'

Interface: IMcpServerVariable

Structure describing a variable related to an MCP server instance.

export interface IMcpServerVariable {
    key: string;
    name: string;
}

Usage Example:

const variable: IMcpServerVariable = {
    key: 'token',
    name: 'Access Token',
};

Interface: IMcpServerInfo

Describes the metadata and configuration properties of an MCP server instance.

export interface IMcpServerInfo {
    id: string;
    name: string;
    url: string;
    server_type: McpServerType;
    description?: string;
    variables?: IMcpServerVariable[];
    headers: Map<string, string>;
}
const serverInfo: IMcpServerInfo = {
    id: 'server-01',
    name: 'Primary SSE Server',
    url: 'https://sse.example.com/mcp',
    server_type: McpServerType.Sse,
    description: 'Handles real-time events via SSE',
    variables: [
        { key: 'authToken', name: 'Authentication Token' }
    ],
    headers: new Map([
        ['Authorization', 'Bearer abc123'],
        ['Accept', 'text/event-stream']
    ]),
};

Implementation Details and Usage Context


Interaction with Other System Components


Visual Diagram

Below is a Mermaid class diagram illustrating the structure and relationships of the types defined in this file:

classDiagram
    class McpServerType {
        <<enumeration>>
        +Sse = 'sse'
        +StreamableHttp = 'streamable-http'
    }

    class IMcpServerVariable {
        +key: string
        +name: string
    }

    class IMcpServerInfo {
        +id: string
        +name: string
        +url: string
        +server_type: McpServerType
        +description?: string
        +variables?: IMcpServerVariable[]
        +headers: Map<string, string>
    }

    IMcpServerInfo --> McpServerType : server_type
    IMcpServerInfo "1" o-- "*" IMcpServerVariable : variables

Summary

This file is essential for ensuring consistent handling of MCP server configurations and can be extended with additional types or fields as the MCP protocol or system requirements evolve.