DEDUPED Hot AI repos. Real use cases. What people build. Get the Monday 5

How to call any MCP server from your own Python code with Fastmcp

Use the FastMCP client to connect to a local or remote server by URL and call its tools programmatically.

Short answer: Install with uv add fastmcp; then read the Clients guide at gofastmcp.com; point a FastMCP client at the server URL; transport negotiation, authentication and protocol lifecycle are handled. All steps.

Who it is forAn engineer testing an MCP server or building an app that uses tools from other MCP servers.

The problemTalking to MCP servers directly means handling transports, auth and protocol lifecycle yourself.

The outcomeA Python script that connects to any MCP server and calls its tools, with transport negotiation managed for you.

What you need first

  • Python and uv (recommended) for installation
  • An MCP client to connect your server to, such as an AI assistant or coding agent
  • For TypeScript projects: the separate fastmcp-ts package

Steps

  1. Install with uv add fastmcp
  2. Read the Clients guide at gofastmcp.com
  3. Point a FastMCP client at the server URL; transport negotiation, authentication and protocol lifecycle are handled
  4. List the server's tools and call them from your script or tests
  5. Use the CLI option from the Clients docs for quick one-off checks

Prompt for your agent

Using PrefectHQ/fastmcp's client, write a Python script that connects to <MCP server URL>, lists its tools, and calls <tool> with <arguments>. Use it as a smoke test I can run in CI.

Caveat. The README describes the client but shows no client code, so use the Clients guide for the exact API.

Use this in your AI agent

Ask your agent

Using the Deduped MCP, get the setup steps for PrefectHQ/fastmcp and "Call any MCP server from your own Python code"

Add Deduped to Claude Code once

claude mcp add --transport http deduped https://dedupedai.com/mcp

Cursor, ChatGPT, others

Share: X LinkedIn Hacker News Email Copy link

Third-party repos we don't own. AI-written use cases can be wrong. Disclaimer