MCP auth, local servers, and server policy
Configure remote auth headers, Node-only local stdio, and tool-only MCP servers safely.
MCP is infrastructure. Your app owns server config, credentials, auth, product policy, and enabled tools.
Remote auth
Pass host-resolved headers into remote config:
import { Effect } from 'effect'
import { FetchHttpClient } from 'effect/http'
import { listRemoteMcpServerTools } from '@yolk-sdk/mcp/client'
const tools = await Effect.runPromise(
listRemoteMcpServerTools({
name: 'figma',
type: 'remote',
url: 'https://mcp.figma.com/mcp',
headers: {
authorization: `Bearer ${figmaAccessToken}`
}
}).pipe(Effect.provide(FetchHttpClient.layer))
)Remote MCP requires HTTPS by default. http://localhost is only for explicit dev policy.
Local stdio
Use @yolk-sdk/mcp/client/node only from Node hosts. It imports @effect/platform-node, an optional
peer of @yolk-sdk/mcp (~4.2.0): install it at the same version as effect.
import { execPath } from 'node:process'
import { Effect } from 'effect'
import { listLocalMcpServerToolsNode } from '@yolk-sdk/mcp/client/node'
const tools = await Effect.runPromise(
listLocalMcpServerToolsNode(
{
name: 'local-files',
type: 'local',
command: [execPath, './mcp-server.mjs'],
environment: {
EXAMPLE_TOKEN: token
}
},
{
securityPolicy: {
allowLocalServers: true,
allowDevHttpLocalhost: false
}
}
)
)Local stdio uses explicit environment only; host environment inheritance is disabled. Prefer an
absolute executable such as execPath. If a bare executable or /usr/bin/env shebang is required,
pass an explicitly allowlisted PATH; never pass the host process environment wholesale.
The client keeps the server's stdin open until it has its answers, and reads every stdout line as
one JSON-RPC message (MCP 2025-11-25, stdio transport). It answers a server ping with an empty
result, answers any other server request with JSON-RPC error -32601 (it declares no client
capability), and ignores notifications such as notifications/message. A line that is not a
JSON-RPC message (including a request or notification whose params is not an object) fails the
operation; write logs to stderr, which the client ignores.
Tool name mapping
MCP tool names become model-visible Yolk tool names by prefixing the sanitized server name:
server: docs
mcp tool: search
agent tool: docs_searchWhen executing a model tool call, map call.name back to the resolved MCP tool and call by raw mcpToolName.
Full MCP v2 server policy
The official Client, McpServer, createMcpHandler, MRTR, subscriptions, and protocol helpers are exported from @yolk-sdk/mcp/client, @yolk-sdk/mcp/server, and @yolk-sdk/mcp/core.
For HTTP servers:
- Validate
OriginandHostbeforecreateMcpHandler().fetch. - Authenticate every stateless request; do not rely on connection or session identity.
- Partition
cacheScope: 'private'entries by authorization context. - Integrity-protect MRTR
requestStatewhen it affects authorization, resource access, or business logic. - Treat self-reported client/server identity and tool annotations as untrusted.
Tool-only MCP server
Expose app-approved Yolk tools over MCP:
import { makeMcpToolServer } from '@yolk-sdk/mcp/server'
const server = makeMcpToolServer({
name: 'yolk-tools',
version: '0.1.0',
tools: approvedTools
})The adapter serves stateless MCP 2026-07-28 and initialize-based legacy HTTP clients for tools/list and tools/call; a 2026-07-28 subscriptions/listen answers its acknowledgement and complete. No tool call outlives handleHttpRequest (see Expose Yolk tools through MCP). It does not own routes, auth, resources, prompts, or deployment. Use the official McpServer exports for the full core protocol.
Policy checklist
- Persist server config outside the SDK.
- Resolve credentials server-side.
- Filter enabled tools per user/session.
- Keep local servers disabled unless a Node host explicitly allows them.
- Audit tool calls and preserve MCP
isError/structuredContent. - Never let browser clients submit arbitrary MCP server configs directly to execution.