---
title: "Building a CLI Client For Model Context Protocol Servers"
description: "A minimal MCP client can run outside Claude Desktop by implementing four pieces: connecting to the server over stdio, listing tools via tools/list, invoking them via tools/call, and looping tool results back into the Anthropic Messages API."
url: "https://swe.quest/articles/building-a-cli-client-for-model-context-protocol-servers-36e215421e2291e4"
canonical: "https://neon.com/blog/building-a-cli-client-for-model-context-protocol-servers"
source: "Neon"
published: "2024-12-20"
difficulty: "medium"
kind: "How-to"
reading_minutes: 5
tags: ["ai-agents","llms","typescript","developer-tools"]
---

# Building a CLI Client For Model Context Protocol Servers

A post on [Neon](https://swe.quest/sources/neon.md), published 2024-12-20, 5 min read, How-to. Original: [https://neon.com/blog/building-a-cli-client-for-model-context-protocol-servers](https://neon.com/blog/building-a-cli-client-for-model-context-protocol-servers)

## Summary

A minimal MCP client can run outside Claude Desktop by implementing four pieces: connecting to the server over stdio, listing tools via tools/list, invoking them via tools/call, and looping tool results back into the Anthropic Messages API. TypeScript code builds this into an interactive CLI with a persisted message history, a chat loop and an entry point that launches the Neon MCP server. The simple version lacks streaming and stops after the first tool call; Neon's published MCP Client CLI handles both.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [AI agents](https://swe.quest/tags/ai-agents.md) (AI & ML)
- [LLMs](https://swe.quest/tags/llms.md) (AI & ML)
- [TypeScript](https://swe.quest/tags/typescript.md) (Languages)
- [Developer tools](https://swe.quest/tags/developer-tools.md) (Engineering practices)

## Prerequisites

- TypeScript/Node.js ([easy posts on TypeScript](https://swe.quest/tags/typescript.md?difficulty=easy))
- LLM tool calling ([easy posts on LLMs](https://swe.quest/tags/llms.md?difficulty=easy))
- Anthropic Messages API

## Keywords

Model Context Protocol, MCP, Claude, Anthropic SDK, Neon MCP Server, Claude Desktop

## Related posts

- [Tiny Agents: an MCP-powered agent in 50 lines of code](https://swe.quest/articles/tiny-agents-an-mcp-powered-agent-in-50-lines-of-code-6bc1baf5d192d871.md): Hugging Face · 2025-04-25 · Medium · 10 min read · AI agents, LLMs, TypeScript
  An LLM agent built on the Model Context Protocol reduces to a simple while loop around an MCP-aware inference client: connect to MCP servers, convert their tools into OpenAI-style function definitions, pass them to the chat-completion call, execute returned tool calls via the MCP SDK, and feed results back.
- [What’s MCP all about? Comparing MCP with LLM function calling](https://swe.quest/articles/what-s-mcp-all-about-comparing-mcp-with-llm-function-calling-fcce1ee01a7d0aed.md): Neon · 2025-03-12 · Medium · 5 min read · AI agents, LLMs, TypeScript
  The Model Context Protocol (MCP) builds on LLM function calling by moving tool definitions and execution out of individual LLM applications into standalone servers that any MCP-compatible client can discover and invoke.
- [How to Build an MCP Server with Gradio](https://swe.quest/articles/how-to-build-an-mcp-server-with-gradio-76a4960460af5603.md): Hugging Face · 2025-04-30 · Medium · 10 min read · AI agents, Python, LLMs
  Gradio apps become Model Context Protocol servers by passing mcp\_server=True to launch(), which auto-converts each Python function into an MCP tool, using its docstring and type hints to build the description and input schema.
- [Tiny Agents in Python: a MCP-powered agent in ~70 lines of code](https://swe.quest/articles/tiny-agents-in-python-a-mcp-powered-agent-in-70-lines-of-code-ec89d52eb52d9576.md): Hugging Face · 2025-05-23 · Medium · 16 min read · AI agents, LLMs, Python
  Hugging Face's huggingface\_hub Python SDK now includes an MCP client and a minimal Agent class, letting an LLM pull tools from MCP servers (stdio, SSE or streamable HTTP) and call them during inference.
- [Better Rails for Agents: A New Remote MCP and Railway Agent in the CLI](https://swe.quest/articles/better-rails-for-agents-a-new-remote-mcp-and-railway-agent-in-the-cli-4b9abaf62a02f3cd.md): Railway · 2026-04-17 · Medium · 13 min read · AI agents, API design, Developer tools, TypeScript
  Railway shipped a remote MCP server at mcp.railway.com, which connects to MCP clients over OAuth with no local install, and a new \`railway agent\` CLI command for interactive, scripted or CI use with JSON output.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
