MCPcopy Create free account
hub / github.com/Effect-TS/effect / McpServer

Class McpServer

packages/effect/src/unstable/ai/McpServer.ts:167–580  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

165 * @since 4.0.0
166 */
167export class McpServer extends Context.Service<McpServer, {
168 readonly notifications: RpcClient.RpcClient<RpcGroup.Rpcs<typeof ServerNotificationRpcs>>
169 readonly initializedClients: Set<number>
170 readonly tools: ReadonlyArray<{
171 readonly tool: McpTool
172 readonly annotations: Context.Context<never>
173 }>
174 readonly addTool: (options: {
175 readonly tool: McpTool
176 readonly annotations: Context.Context<never>
177 readonly handle: (payload: any) => Effect.Effect<CallToolResult, InternalError | InvalidParams, McpServerClient>
178 }) => Effect.Effect<void>
179 readonly callTool: (
180 requests: typeof CallTool.payloadSchema.Type
181 ) => Effect.Effect<CallToolResult, InternalError | InvalidParams, McpServerClient>
182
183 readonly resources: ReadonlyArray<{
184 readonly resource: Resource
185 readonly annotations: Context.Context<never>
186 }>
187 readonly addResource: (options: {
188 readonly resource: Resource
189 readonly annotations: Context.Context<never>
190 readonly handle: Effect.Effect<typeof ReadResourceResult.Type, InternalError, McpServerClient>
191 }) => Effect.Effect<void>
192
193 readonly resourceTemplates: ReadonlyArray<{
194 readonly template: ResourceTemplate
195 readonly annotations: Context.Context<never>
196 }>
197 readonly addResourceTemplate: (
198 options: {
199 readonly template: ResourceTemplate
200 readonly annotations: Context.Context<never>
201 readonly routerPath: string
202 readonly completions: Record<
203 string,
204 (
205 input: string,
206 context: CompletionContext
207 ) => Effect.Effect<CompleteResult, InternalError>
208 >
209 readonly handle: (
210 uri: string,
211 params: Array<string>
212 ) => Effect.Effect<
213 typeof ReadResourceResult.Type,
214 InvalidParams | InternalError,
215 McpServerClient
216 >
217 }
218 ) => Effect.Effect<void>
219
220 readonly findResource: (
221 uri: string
222 ) => Effect.Effect<typeof ReadResourceResult.Type, McpErrorBase | InvalidParams | InternalError, McpServerClient>
223
224 readonly prompts: ReadonlyArray<{

Callers

nothing calls this directly

Calls 15

makeUriMatcherFunction · 0.85
offerUnsafeMethod · 0.80
pushMethod · 0.80
registerMethod · 0.80
handleFunction · 0.70
makeMethod · 0.65
setMethod · 0.65
writeMethod · 0.65
ofMethod · 0.65
pipeMethod · 0.65

Tested by

no test coverage detected