/ src / types / mcp.d.ts
mcp.d.ts
  1  import type {
  2    CallToolRequest,
  3    CallToolResult,
  4    ListToolsRequest,
  5    ListToolsResult,
  6    ListResourcesRequest,
  7    ListResourcesResult,
  8    ReadResourceRequest,
  9    ReadResourceResult,
 10    ListPromptsRequest,
 11    ListPromptsResult,
 12    GetPromptRequest,
 13    GetPromptResult,
 14    Implementation as McpServerImplementation
 15  } from '@modelcontextprotocol/sdk/types.d.ts'
 16  
 17  import { StdioServerParameters } from '@modelcontextprotocol/sdk/client/stdio.js'
 18  
 19  import { McpbManifestAny, McpbUserConfigValues } from '@anthropic-ai/mcpb'
 20  
 21  export type TypedAsyncFunction<Args extends any[], Result> = (..._args: Args) => Promise<Result>
 22  
 23  export type McpAsyncToolsList = TypedAsyncFunction<[ListToolsRequest], ListToolsResult>
 24  export type McpAsyncToolsCall = TypedAsyncFunction<[CallToolRequest], CallToolResult>
 25  
 26  export type McpAsyncPromptsList = TypedAsyncFunction<[ListPromptsRequest], ListPromptsResult>
 27  export type McpAsyncPromptsGet = TypedAsyncFunction<[GetPromptRequest], GetPromptResult>
 28  
 29  export type McpAsyncResourcesList = TypedAsyncFunction<[ListResourcesRequest], ListResourcesResult>
 30  export type McpAsyncResourcesRead = TypedAsyncFunction<[ReadResourceRequest], ReadResourceResult>
 31  
 32  export type AsyncFunction =
 33    | McpAsyncToolsList
 34    | McpAsyncToolsCall
 35    | McpAsyncPromptsList
 36    | McpAsyncPromptsGet
 37    | McpAsyncResourcesList
 38    | McpAsyncResourcesRead
 39  
 40  export type userConfigValue = McpbUserConfigValues[string]
 41  
 42  export type McpMetadataStdio = {
 43    name: string
 44    type: 'metadata__stdio_config'
 45    config: StdioServerParameters
 46    description?: McpServerDescription
 47  }
 48  
 49  type McpDxtError = {
 50    field: string
 51    message: string
 52  }
 53  
 54  export type McpDxtErrors = {
 55    errors: McpDxtError[]
 56  }
 57  
 58  export type { McpbManifestAny }
 59  
 60  export type McpMetadataDxt = {
 61    name: string
 62    type: 'metadata__mcpb_manifest'
 63    config: McpbManifestAny | McpDxtErrors
 64    user_config?: McpbUserConfigValues
 65  }
 66  
 67  export type McpMetadata = McpMetadataStdio | McpMetadataDxt
 68  
 69  export type McpObject = {
 70    metadata?: McpMetadata
 71    tools?: {
 72      list?: McpAsyncToolsList
 73      call?: McpAsyncToolsCall
 74    }
 75    prompts?: {
 76      list?: McpAsyncPromptsList
 77      get?: McpAsyncPromptsGet
 78    }
 79    resources?: {
 80      list?: McpAsyncResourcesList
 81      read?: McpAsyncResourcesRead
 82    }
 83  }
 84  
 85  export type McpToolType = ListToolsResult['tools'][number]
 86  
 87  export type ToolType = {
 88    name: McpToolType['name']
 89    description: McpToolType['description']
 90    // Rename inputSchema to parameters to comply with the OpenAI SDK
 91    parameters: McpToolType['inputSchema']
 92  }
 93  
 94  export type MCPAPI = Record<string, McpObject>
 95  
 96  export type DXTAPI = Record<string, McpbManifestAny>
 97  
 98  export type ClientProfile = {
 99    name: string
100    tools?: Record<string, string>
101    prompts?: Record<string, string>
102    resources?: Record<string, string>
103    config?: StdioServerParameters
104    description?: McpServerDescription
105  }
106  
107  export type McpServerDescription = {
108    instructions: string
109    implementation: McpServerImplementation
110  }