Home / File/ types.ts — mcp Source File

types.ts — mcp Source File

Architecture documentation for types.ts, a typescript file in the mcp codebase. 2 imports, 5 dependents.

File typescript McpServer Configuration 2 imports 5 dependents 3 functions

Entity Profile

Dependency Diagram

graph LR
  5c6acde2_5ba8_604f_70ae_120f7b72feaa["types.ts"]
  7d30b0b7_0151_e99e_5f8e_3f5a7c1d60dd["sdk"]
  5c6acde2_5ba8_604f_70ae_120f7b72feaa --> 7d30b0b7_0151_e99e_5f8e_3f5a7c1d60dd
  8c03d5ca_533e_b509_c9c8_f2625f78856a["types.js"]
  5c6acde2_5ba8_604f_70ae_120f7b72feaa --> 8c03d5ca_533e_b509_c9c8_f2625f78856a
  108c9ff4_bdb8_518a_9256_9ff4cd9d39a7["graph-cache.ts"]
  108c9ff4_bdb8_518a_9256_9ff4cd9d39a7 --> 5c6acde2_5ba8_604f_70ae_120f7b72feaa
  54581714_e921_5e5e_17c6_d2040cdc3b55["server.ts"]
  54581714_e921_5e5e_17c6_d2040cdc3b55 --> 5c6acde2_5ba8_604f_70ae_120f7b72feaa
  242ec636_ba33_547c_5cb6_5f619c73d099["overview.ts"]
  242ec636_ba33_547c_5cb6_5f619c73d099 --> 5c6acde2_5ba8_604f_70ae_120f7b72feaa
  ca77ccf4_30df_6b5c_22dc_f7ba42fd0765["symbol-context.ts"]
  ca77ccf4_30df_6b5c_22dc_f7ba42fd0765 --> 5c6acde2_5ba8_604f_70ae_120f7b72feaa
  4bef1572_5a60_651d_3247_2779d2e6bd57["api-helpers.ts"]
  4bef1572_5a60_651d_3247_2779d2e6bd57 --> 5c6acde2_5ba8_604f_70ae_120f7b72feaa
  style 5c6acde2_5ba8_604f_70ae_120f7b72feaa fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { SupermodelClient } from '@supermodeltools/sdk';
import { Tool } from '@modelcontextprotocol/sdk/types.js';

export interface ClientContext {
  graphs: SupermodelClient;
}

type ContentBlock =
  | { type: 'text'; text: string }
  | { type: 'image'; data: string; mimeType: string }
  | { type: 'audio'; data: string; mimeType: string }
  | { type: 'resource'; resource: unknown };

export type ToolCallResult = {
  content: ContentBlock[];
  isError?: boolean;
};

export type HandlerFunction = (
  client: ClientContext,
  args: Record<string, unknown> | undefined,
  defaultWorkdir?: string
) => Promise<ToolCallResult>;

export type Endpoint = {
  tool: Tool;
  handler: HandlerFunction;
};

export function asTextContentResult(result: unknown): ToolCallResult {
  return {
    content: [
      {
        type: 'text',
        text: typeof result === 'string' ? result : JSON.stringify(result, null, 2),
      },
    ],
    isError: false
  };
}

/**
 * Structured error types for agent-parseable error responses.
 * Agents can use these to decide whether to retry, fallback, or report.
 */
type ErrorType =
  | 'authentication_error'
  | 'authorization_error'
  | 'rate_limit_error'
  | 'timeout_error'
  | 'resource_error'
  | 'validation_error'
  | 'network_error'
  | 'internal_error'
  | 'not_found_error'
  | 'cache_error';

export interface StructuredError {
  type: ErrorType;
  message: string;
  code: string;
  recoverable: boolean;
  suggestion?: string;
  details?: Record<string, unknown>;
  reportable?: boolean;
  repo?: string;
}

export function asErrorResult(error: string | StructuredError): ToolCallResult {
  const text = typeof error === 'string'
    ? error
    : JSON.stringify({ error }, null, 2);

  return {
    content: [
      {
        type: 'text',
        text,
      },
    ],
    isError: true,
  };
}

Domain

Subdomains

Dependencies

  • sdk
  • types.js

Frequently Asked Questions

What does types.ts do?
types.ts is a source file in the mcp codebase, written in typescript. It belongs to the McpServer domain, Configuration subdomain.
What functions are defined in types.ts?
types.ts defines 3 function(s): asErrorResult, asTextContentResult, client.
What does types.ts depend on?
types.ts imports 2 module(s): sdk, types.js.
What files import types.ts?
types.ts is imported by 5 file(s): api-helpers.ts, graph-cache.ts, overview.ts, server.ts, symbol-context.ts.
Where is types.ts in the architecture?
types.ts is located at src/types.ts (domain: McpServer, subdomain: Configuration, directory: src).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free