Mcp
An MCP server as a tool source, reached over Streamable HTTP with an HTTP client the caller has already given the credentials the server asks for, so no credential enters this package. The source asks the server for its tools and runs them, and nothing else of MCP: resources, prompts, and the requests a server makes of its client are left out.
How the server is spoken to, statelessly or with a session, is the transport’s to settle. The source adds what only tools have: the headers that mirror the parameters a tool marks.
Since v0.1.0
Constructors
Section titled “Constructors”Makes a source of the tools of the MCP server at options.url. Making it contacts nothing: the
server is first reached when the source lists or runs its tools. A tool that reports isError
fails as CallFailedError, with what it said, and one that asks for input first as
UnsupportedError.
Example (A source of an MCP server, with the server’s credentials on the client)
import { Mcp } from "@amends-dev/toolkit"import { Config, Effect, Redacted } from "effect"import { FetchHttpClient, HttpClient, HttpClientRequest } from "effect/http"
const program = Effect.gen(function* () { const token = yield* Config.Redacted("MCP_TOKEN") // The client carries the credentials, so the source never sees them. const client = (yield* HttpClient.HttpClient).pipe( HttpClient.mapRequest(HttpClientRequest.bearerToken(Redacted.value(token))) ) const tasks = yield* Mcp.http({ name: "tasks", url: "https://mcp.example.com/mcp", client }) // The server is first reached here: the catalog stores what it lists. const definitions = yield* tasks.discover const result = yield* tasks.call("list_tasks", { status: "open" }) return { definitions, result }}).pipe(Effect.provide(FetchHttpClient.layer))Signature
declare const http: (options: Transport.Options) => Effect.Effect<ToolSource.ToolSource, never, never>Since v0.1.0
Options
Section titled “Options”Options
Section titled “Options”What http takes: the source’s name, the server’s address, the client that sends its
requests with the server’s credentials, and how long a request may take.
Signature
declare const Options: Transport.OptionsSince v0.1.0