# AI use cases for Fastmcp (PrefectHQ/fastmcp)

Repo: [PrefectHQ/fastmcp](https://github.com/PrefectHQ/fastmcp) | Use cases: 3 | Page: https://dedupedai.com/use-cases/prefecthq-fastmcp/

FastMCP is a Python framework for building Model Context Protocol servers, clients and interactive apps. You declare a tool as an ordinary Python function and FastMCP generates the schema, validation and documentation; clients connect to any server by URL with transport, authentication and lifecycle handled. Apps give tools interactive UIs rendered inside the conversation, and there is an official TypeScript counterpart.

This file holds every use case of this repo. Each one starts with a "## " heading and ends with its URL.

- Turn your Python functions into MCP tools: https://dedupedai.com/use-cases/prefecthq-fastmcp/turn-python-functions-into-mcp-tools/
- Call any MCP server from your own Python code: https://dedupedai.com/use-cases/prefecthq-fastmcp/script-calls-to-any-mcp-server/
- Have your coding agent build an MCP server for you: https://dedupedai.com/use-cases/prefecthq-fastmcp/give-your-coding-agent-fastmcp-docs/

## How to turn your Python functions into MCP tools with Fastmcp

Repo: [PrefectHQ/fastmcp](https://github.com/PrefectHQ/fastmcp) | Difficulty: Beginner | Time: 20 minutes | Basis: From the README

Wrap existing functions with FastMCP so any AI assistant that speaks MCP can call them.

**Who it is for:** A developer with internal scripts who wants Claude or a coding agent to use them directly.

**The problem:** Writing an MCP server by hand means schemas, validation and protocol handling before any real logic.

**The outcome:** A working MCP server whose tools are plain Python functions, with schemas and docs generated for you.

### Steps

1. Run `uv add fastmcp` in your project
2. Create an instance with `mcp = FastMCP("Demo 🚀")` and decorate each function with @mcp.tool
3. Give each function type hints and a docstring; FastMCP builds the schema, validation and documentation from them
4. Call mcp.run() under the main guard, as in the README example, and start the script
5. Connect the server to your MCP client following the quickstart

### Prompt to paste into your agent

```text
Using PrefectHQ/fastmcp, turn these Python functions into an MCP server: <list functions>. Add type hints and docstrings so the schemas are generated automatically, then connect it to my <MCP client> and test each tool.
```

### Caveat

A tool runs with your machine's permissions, so only expose functions you would be comfortable letting an AI call.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/prefecthq-fastmcp/turn-python-functions-into-mcp-tools/

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

Repo: [PrefectHQ/fastmcp](https://github.com/PrefectHQ/fastmcp) | Difficulty: Intermediate | Time: 30 minutes | Basis: From the README

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

**Who it is for:** An engineer testing an MCP server or building an app that uses tools from other MCP servers.

**The problem:** Talking to MCP servers directly means handling transports, auth and protocol lifecycle yourself.

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

### 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 to paste into your agent

```text
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.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/prefecthq-fastmcp/script-calls-to-any-mcp-server/

## How to have your coding agent build an MCP server for you with Fastmcp

Repo: [PrefectHQ/fastmcp](https://github.com/PrefectHQ/fastmcp) | Difficulty: Beginner | Time: 20 minutes | Basis: From the README

Point Claude Code or Cursor at FastMCP's llms.txt so it writes a server against current docs.

**Who it is for:** A developer who would rather describe a tool than learn the MCP spec.

**The problem:** Coding agents trained on older MCP code often produce servers that use outdated APIs.

**The outcome:** A coding agent working from FastMCP's version-matched documentation to write and test your server.

### Steps

1. Give your coding agent https://gofastmcp.com/llms.txt as its starting point
2. Use llms-full.txt only if your model has room, since it may exceed the context window
3. See the Coding Agents page for version-matched docs and the optional server authoring skill
4. Ask the agent to add FastMCP with `uv add fastmcp` and build the server
5. Review every exposed tool before connecting the server to your assistant

### Prompt to paste into your agent

```text
Read https://gofastmcp.com/llms.txt and build me a FastMCP server (PrefectHQ/fastmcp) that exposes <capability> as tools. Use the current FastMCP API, add type hints and docstrings, and give me the exact steps to connect it to <MCP client>.
```

### Caveat

Check the version your agent targets: the README lists upgrade guides from FastMCP 2 and 3 and from MCP SDK v1 and v2, so APIs differ across versions.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/prefecthq-fastmcp/give-your-coding-agent-fastmcp-docs/
