fastmcp icon indicating copy to clipboard operation
fastmcp copied to clipboard

Documentation for using FastMCP as an MCP Client

Open strawgate opened this issue 3 months ago β€’ 1 comments

Enhancement

We should advertise FastMCP Client as a great way to add MCP tools to your existing code, chat application or AI agent framework.

We should include examples use cases in the docs for this

strawgate avatar Oct 04 '25 13:10 strawgate

Claude finished @strawgate's task β€”β€” View job


Investigation Complete

Issue Type: Documentation Enhancement

Recommendation

Create a dedicated "Use Cases" documentation page highlighting FastMCP Client as a powerful way to integrate MCP tools into existing applications. The existing client documentation is technically comprehensive but doesn't effectively advertise the client's value proposition or provide compelling use case examples.

The documentation should emphasize three primary integration patterns:

  1. AI SDK Integration - Adding MCP tools to AI applications (Anthropic, OpenAI, Gemini)
  2. Testing & Development - Using the client to test MCP servers during development
  3. Agent Framework Integration - Building custom AI agents that leverage MCP tools

Findings

Current State

Existing Client Documentation (docs/clients/):

  • βœ… Comprehensive technical coverage of Client API
  • βœ… Good examples of transports, auth, and operations
  • βœ… Covers multi-server configuration
  • ❌ Missing: Value proposition / "why use this" framing
  • ❌ Missing: Real-world integration examples
  • ❌ Missing: Use case-driven examples

Existing Integration Examples:

  • AI SDKs: Anthropic (docs/integrations/anthropic.mdx), OpenAI (docs/integrations/openai.mdx), Gemini (docs/integrations/gemini.mdx)
    • These show how to connect FastMCP servers TO the AI SDKs
    • ❌ Missing reverse: Using FastMCP Client to ADD tools to AI applications
  • Testing Pattern: Well-documented in AGENTS.md and test files
    • Shows in-memory transport pattern
    • βœ… Good foundation but buried in developer docs

Gap Analysis:

  1. The client is positioned as a "programmatic interface" but not as a solution for common problems
  2. Integration examples show "MCP server β†’ AI SDK" but not "FastMCP Client β†’ your code"
  3. No dedicated page for "adding MCP to your existing application"
  4. Use cases are scattered across different docs rather than centralized
Related Items Context

Issue #1839 - "MCP Client from multiple in memory servers"

  • Shows user confusion about client capabilities
  • Demonstrates need for clearer multi-server examples
  • Resolved with proxy pattern explanation

Issue #1878 - "Add more Transformation Examples"

  • Shows related need for client usage patterns
  • Focused on tool transformation (exposing client methods as tools)
  • Complementary to this request (that's about consuming tools, this is about providing them)

PR #2002 - "Additional Tool Transformation Examples"

  • Recently added examples for client wrapping patterns
  • Shows pattern of improving practical examples

Detailed Action Plan

1. Create New Documentation Page: docs/clients/use-cases.mdx

Structure:

---
title: FastMCP Client Use Cases
description: Real-world examples of integrating MCP tools into your applications
---

## Why Use FastMCP Client?

FastMCP Client provides a programmatic way to add MCP tools to any Python application...

## Use Case 1: Integrating with AI SDKs

### Anthropic SDK
[Example: Adding weather tools to Claude API calls]

### OpenAI SDK  
[Example: Adding database tools to GPT applications]

### LangChain
[Example: Creating LangChain tools from MCP servers]

## Use Case 2: Building Custom AI Agents

[Example: Agent that uses multiple MCP servers]
[Example: Agentic loop with tool selection]

## Use Case 3: Testing MCP Servers

[Example: In-memory testing pattern]
[Example: Integration test setup]

## Use Case 4: Chat Applications

[Example: Adding tools to custom chat interface]
[Example: Multi-turn conversations with tool use]

2. Update docs/clients/client.mdx

Add section near the top (after "Creating a Client"):

## Why Use the FastMCP Client?

The FastMCP Client is ideal for:

- **πŸ€– AI Integration**: Add MCP tools to applications built with Anthropic, OpenAI, or other AI SDKs
- **πŸ§ͺ Testing**: Test your MCP servers during development with in-memory connections
- **🀝 Agent Frameworks**: Build custom AI agents that leverage multiple MCP servers
- **πŸ’¬ Chat Apps**: Enhance chat applications with dynamically loaded tools

For detailed examples of each use case, see [Use Cases](/clients/use-cases).

3. Create Example Code Files

examples/client_integrations/anthropic_client.py:

"""Example: Using FastMCP Client to add tools to Anthropic SDK."""

examples/client_integrations/openai_client.py:

"""Example: Using FastMCP Client to add tools to OpenAI SDK."""

examples/client_integrations/custom_agent.py:

"""Example: Building a custom agent with FastMCP Client."""

4. Update Navigation

In docs/docs.json, add to Clients section:

{
  "group": "Essentials",
  "icon": "cube",
  "pages": [
    "clients/client",
    "clients/use-cases",  // NEW
    "clients/transports"
  ]
}

5. Update README.md

Add to "MCP Clients" section (line ~240):

The FastMCP Client is not just for testing - it's a powerful way to integrate MCP tools into any Python application, including:
- AI applications built with Anthropic, OpenAI, or Gemini SDKs
- Custom AI agent frameworks
- Chat applications requiring dynamic tool loading

Related Files

Documentation Files to Create/Modify
File Action Purpose
docs/clients/use-cases.mdx CREATE New dedicated use cases page
docs/clients/client.mdx MODIFY Add "Why Use" section with value prop
examples/client_integrations/anthropic_client.py CREATE Example: MCP tools + Anthropic SDK
examples/client_integrations/openai_client.py CREATE Example: MCP tools + OpenAI SDK
examples/client_integrations/custom_agent.py CREATE Example: Custom agent with multiple servers
docs/docs.json MODIFY Add use-cases to navigation
README.md MODIFY Enhance MCP Clients section
Key Reference Files
File Relevance Key Sections
docs/clients/client.mdx Current client overview Lines 1-291: Complete client documentation
docs/integrations/anthropic.mdx Shows server→SDK pattern Lines 1-229: Could be adapted for reverse (Client→SDK)
docs/integrations/gemini.mdx Shows direct client usage Lines 58-82: Good example of Client + AI SDK
README.md Main project overview Lines 240-299: MCP Clients section