Blog Post

Microsoft Developer Community Blog
4 MIN READ

MCP vs mcp-cli: Dynamic Tool Discovery for Token-Efficient AI Agents

anbonagi's avatar
anbonagi
Icon for Microsoft rankMicrosoft
Mar 06, 2026

Introduction

The AI agent ecosystem is evolving rapidly, and with it comes a scaling challenge that many developers are hitting context window bloat. When building systems that integrate with multiple MCP (Model Context Protocol) servers, you're forced to load all tool definitions upfront—consuming thousands of tokens just to describe what tools could be available.

mcp-cli: a lightweight tool that changes how we interact with MCP servers. But before diving into mcp-cli, it's essential to understand the foundational protocol itself, the design trade-offs between static and dynamic approaches, and how they differ fundamentally.

Part 1: Understanding MCP (Model Context Protocol)

What is MCP?

The Model Context Protocol (MCP) is an open standard for connecting AI agents and applications to external tools, APIs, and data sources. Think of it as a universal interface that allows:

  • AI Agents (Claude, Gemini, etc.) to discover and call tools
  • Tool Providers to expose capabilities in a standardized way
  • Seamless Integration between diverse systems without custom adapters
  • New to MCP see https://aka.ms/mcp-for-beginners 

How MCP Works

MCP operates on a simple premise: define tools with clear schemas and let clients discover and invoke them.

Basic MCP Flow:

Tool Provider (MCP Server) ↓ [Tool Definitions + Schemas] ↓ AI Agent / Client ↓ [Discover Tools] → [Invoke Tools] → [Get Results]

Example: A GitHub MCP server exposes tools like:

  • search_repositories - Search GitHub repos
  • create_issue - Create a GitHub issue
  • list_pull_requests - List open PRs

Each tool comes with a JSON schema describing its parameters, types, and requirements.

The Static Integration Problem

Traditionally, MCP integration works like this:

  1. Startup: Load ALL tool definitions from all servers
  2. Context Window: Send every tool schema to the AI model
  3. Invocation: Model chooses which tool to call
  4. Execution: Tool is invoked and result returned

The Problem:

When you have multiple MCP servers, the token cost becomes substantial:

ScenarioToken Count
6 MCP Servers, 60 tools (static loading)~47,000 tokens
After dynamic discovery~400 tokens
Token Reduction99% 🚀

For a production system with 10+ servers exposing 100+ tools, you're burning through thousands of tokens just describing capabilities, leaving less context for actual reasoning and problem-solving.

Key Issues:

  • ❌ Reduced effective context length for actual work
  • ❌ More frequent context compactions
  • ❌ Hard limits on simultaneous MCP servers
  • ❌ Higher API costs

 

Part 2: Enter mcp-cli – Dynamic Context Discovery

What is mcp-cli?

mcp-cli is a lightweight CLI tool (written in Bun, compiled to a single binary) that implements dynamic context discovery for MCP servers. Instead of loading everything upfront, it pulls in information only when needed.

Static vs. Dynamic: The Paradigm Shift

Traditional MCP (Static Context):

AI Agent Says: "Load all tool definitions from all servers" ↓ Context Window Bloat ❌ ↓ Limited space for reasoning

mcp-cli (Dynamic Discovery):

AI Agent Says: "What servers exist?" ↓ mcp-cli responds AI Agent Says: "What are the params for tool X?" ↓ mcp-cli responds AI Agent Says: "Execute tool X" mcp-cli executes and responds

Result: You only pay for information you actually use. ✅

Core Capabilities

mcp-cli provides three primary commands:

1. Discover - What servers and tools exist?

mcp-cli

Lists all configured MCP servers and their tools.

2. Inspect - What does a specific tool do?

mcp-cli info <server> <tool>

Returns the full JSON schema for a tool (parameters, descriptions, types).

3. Execute - Run a tool

mcp-cli call <server> <tool> '{"arg": "value"}'

Executes the tool and returns results.

Key Features of mcp-cli

FeatureBenefit
Stdio & HTTP SupportWorks with both local and remote MCP servers
Connection PoolingLazy-spawn daemon avoids repeated startup overhead
Tool FilteringControl which tools are available via allowedTools/disabledTools
Glob SearchingFind tools matching patterns: mcp-cli grep "*mail*"
AI Agent ReadyDesigned for use in system instructions and agent skills
LightweightSingle binary, minimal dependencies

Part 3: Detailed Comparison Table

AspectTraditional MCPmcp-cli
ProtocolHTTP/REST or StdioStdio/HTTP (via CLI)
Context LoadingStatic (upfront)Dynamic (on-demand)
Tool DiscoveryAll at onceLazy enumeration
Schema InspectionPre-loadedOn-request
Token UsageHigh (~47k for 60 tools)Low (~400 for 60 tools)
Best ForDirect server integrationAI agent tool use
ImplementationServer-side focusCLI-side focus
ComplexityMediumLow (CLI handles it)
Startup TimeOne callMultiple calls (optimized)
ScalingLimited by contextUnlimited (pay per use)
IntegrationCustom implementationPre-built mcp-cli

 

Part 4: When to Use Each Approach

Use Traditional MCP (HTTP Endpoints) when:

  • ✅ Building a direct server integration
  • ✅ You have few tools (< 10) and don't care about context waste
  • ✅ You need full control over HTTP requests/responses
  • ✅ You're building a specialized integration (not AI agents)
  • ✅ Real-time synchronous calls are required

Use mcp-cli when:

  • ✅ Integrating with AI agents (Claude, Gemini, etc.)
  • ✅ You have multiple MCP servers (> 2-3)
  • ✅ Token efficiency is critical
  • ✅ You want a standardized, battle-tested tool
  • ✅ You prefer CLI-based automation
  • ✅ Connection pooling and lazy loading are beneficial
  • ✅ You're building agent skills or system instructions

Conclusion

MCP (Model Context Protocol) defines the standard for tool sharing and discovery. mcp-cli is the practical tool that makes MCP efficient for AI agents by implementing dynamic context discovery.

The fundamental difference:

 MCPmcp-cli
WhatThe protocol standardThe CLI tool
WhereBoth server and clientClient-side CLI
Problem SolvedTool standardizationContext bloat
ArchitectureProtocolImplementation

Think of it this way: MCP is the language, mcp-cli is the interpreter that speaks fluently.

For AI agent systems, dynamic discovery via mcp-cli is becoming the standard. For direct integrations, traditional MCP HTTP endpoints work fine. The choice depends on your use case, but increasingly, the industry is trending toward mcp-cli for its efficiency and scalability.

Resources

Updated Feb 26, 2026
Version 1.0
No CommentsBe the first to comment