Page 1 of 8~112 min topic

MCP in code

Frame the MCP stdio client experiment

Page 1 sets a falsifiable claim for the MCP stdio client calling one local tool before any implementation work begins.

~14 min this pageExperiment brief

1Try it yourself

Playground

Wire MCP in your stack

MCP standardizes tool connections — your app still validates every call.

  1. Run MCP server (tools expose resources)
  2. Register server in client config
  3. List tools from server at runtime
  4. Route model tool call → MCP execute

2Learn the idea

Read

Name the deliverable and claim

Success is not “I followed the tutorial.” Success is producing evidence that: discovered tool schemas are printed; only named tool executes with validated args. The accepted input is narrow on purpose: stdio server command, tool name, args. That narrowness is what lets you inspect every field and prevents a toy demo from being narrated as a production system.

Record the baseline you must beat: direct function call without MCP discovery. If the finished artifact cannot beat that baseline on the fixture below, stop and revise the claim before writing more code.

Read

Inventory the fixture

export const acceptance = {
  project: "an MCP client that connects to a local stdio server, discovers tools, and calls one read-only tool",
  invariant: "the client trusts only configured servers and intersects discovered tools with a local allowlist",
  expected: "The client discovers echo, calls it once, prints \u201chello\u201d, and closes the transport.",
} as const;

Expected evidence: The client discovers echo, calls it once, prints “hello”, and closes the transport.. Treat the printout as a claim about this fixture, not as proof that the toolchain merely started.

Read

Spot misleading success early

For the MCP stdio client calling one local tool, a decorative win often looks like a clean run that never checks discovery count; successful call; timeout on hung server. Write the metric down now so later pages cannot redefine success after the fact. Also note the operational threat you will eventually gate on: auto-approving every discovered tool including filesystem writes.

Read

Lab notebook: claim before code

For mcp-in-code, write the claim on a sticky note in this exact shape: “Given stdio server command, tool name, args, the MCP stdio client will …”. Fill the ellipsis with the observable part of: discovered tool schemas are printed; only named tool executes with validated args. Tape the baseline beside it: direct function call without MCP discovery. If someone later replaces your metric with a vibe check, the sticky note is how you push back.

Also sketch the one-sentence user story: a person uses this output to connect to a local MCP server, list tools, and invoke one allowlisted tool safely. If that sentence needs a dashboard, a model zoo, or five services, the lab scope is too wide—shrink the fixture (local stdio server exposing one read-only echo tool) until the story fits on one screen.

Read

Worked judgment

Decide now whether live network calls are allowed on page 1. For this lab they usually are not; inventory and contracts should run offline against local stdio server exposing one read-only echo tool. Note the metric you will eventually require (discovery count; successful call; timeout on hung server) so page 4 cannot invent a softer target. The characteristic failure to keep in mind is calling a tool not in the discovered list, or hanging on stderr noise.

Read

Why this stage matters for the MCP stdio client

At the experiment brief stage for mcp-in-code, the job is narrower than finishing a product demo. You are creating one progressive evidence piece about local stdio server exposing one read-only echo tool that later pages inherit without redefining success. Keep that fixture small enough to inspect by hand, keep outputs copy-pasteable as text, and refuse to narrate this baseline as if it were a production SLA: direct function call without MCP discovery.

For this page specifically, success looks like a falsifiable claim and baseline written before coding while still centering the user decision to connect to a local MCP server, list tools, and invoke one allowlisted tool safely. If you cannot point to a file, command, or assertion that proves that for the MCP stdio client, stay on this page instead of advancing.

Glossary: tool · Glossary: structured output · Cheatsheet: production ops signals

Next

Go deeper

Before you start

Why this matters

On paper, write the user decision this lab supports: connect to a local MCP server, list tools, and invoke one allowlisted tool safely. Then write one sentence naming what could look successful while actually being wrong for this claim—focus on calling a tool not in the discovered list, or hanging on stderr noise. Keep both sentences beside the fixture inventory you run next.

In the wild

See how this idea shows up as a product and a company — then come back to the lesson. Skills transfer across vendors.

Check your understanding

Page assessment

Answer from memory. Completion is saved from this evidence, not from opening the next page.

1. What exact claim can this fixture disprove?
2. Which baseline prevents a decorative success story?
3. What result would make you stop before implementation?
4. Did you name the metric (discovery count) up front?

All responses are required.