MCP servers
An MCP server offers tools over the Model Context Protocol. AI.McpServer gives a server a name, and an Effect AI McpClient Layer says how to reach it. The harness asks the server for its tools and gives them to the model beside your own.
Declare a server
Section titled “Declare a server”A server is a class with a name. Its Layer is the client: here a server reached over HTTP.
import * as AI from "@alchemy.run/ai";import { McpClient, McpProtocol } from "effect/ai";import * as FetchHttpClient from "effect/http/FetchHttpClient";import * as Layer from "effect/Layer";
export class Docs extends AI.McpServer<Docs>()("docs") {}
export const DocsLive = Docs.layer( McpClient.layerHttp({ name: "my-agent", version: "1.0.0", protocol: McpProtocol.v2025_11_25, url: "https://docs.example.com/mcp", }).pipe(Layer.provide(FetchHttpClient.layer)),);The harness builds the client where it runs, so the client can use a Worker’s service binding or any other transport Effect AI has.
Mention it in a process
Section titled “Mention it in a process”A process that mentions the server may call every tool the server offers:
import * as AI from "@alchemy.run/ai";import { Docs } from "./Docs.mcp.ts";
export class Support extends AI.Process<Support>()("Support", { description: "Answer a question about the product from its documentation.",})` Answer the question you are asked. Look everything up in ${Docs} first.` {}The harness asks the server for its tools when an instance opens, so the tools the model sees are the ones the server has then.
How its tools are named
Section titled “How its tools are named”Each harness names an MCP server’s tools its own way, so the model can tell two servers’ tools apart. On Pi, the search tool of docs is mcp__docs__search. On OpenCode it is docs_search.
The server’s calls are made from your harness, with the client Layer you provided. Credentials for the server stay in your runtime.
See MCP servers on Pi and MCP servers on OpenCode.