Skip to main content

Command Palette

Search for a command to run...

Python FastMCP()

Updated
3 min read
S

Skugan is a seasoned technology leader with over 15 years of progressive experience in the software and cloud industry. He possesses deep expertise across Technical Account Management, Program Management, IT Consulting, Pre-Sales, and complex Project Delivery. Skugan has consistently played a pivotal leadership role in large-scale customer transformation programs, delivering successful outcomes through strong stakeholder collaboration, strategic decision-making, and disciplined execution. Notable achievements include leading the Customer Environment Replication for SAP BOBJ, ECC Validation Environment setup, and currently driving a strategic SAP Cloud for Customer (C4C) migration to AWS, initiatives that have earned him multiple recognitions and awards. Customer-centric by approach, Skugan has guided numerous enterprises in achieving their digital transformation goals, enabling seamless transitions from legacy systems to modern cloud-native architectures. His technical proficiency spans a wide range of platforms and solutions, including:

Cloud: AWS (10 X certified), Microsoft Azure (certified) SAP Portfolio: SAP BusinessObjects BI, SAP Data Intelligence, SAP HANA, SAP Cloud for Customer (C4C), SAP Customer Data Cloud, SAP Commerce Cloud, SAP C4C V1, SAP Sales and Service Cloud V2, SAP Sales Cloud V2 Integration Support with S4HANA AI: GenAI, Agentic AI, Azure OpenAI, RAG Based Frameworks, Langchain, Langraph, LlamaIndex etc.,

Skugan is recognized for his ability to manage complex, high-stakes programs with exceptional planning, prioritization, delegation, and people-management skills. He has trained and mentored more than 180 colleagues on AWS and Azure technologies and has designed and delivered numerous global workshops on cloud adoption, SAP on hyperscalers, and modern data & AI architectures. His blend of technical depth, customer focus, and proven program leadership makes him a trusted advisor and transformation partner for enterprises embarking on cloud, data, and AI journeys

What is Python FastMCP ?

Python FastMCP is a high-level, Pythonic framework designed for building MCP (Model Context Protocol) servers and clients easily and efficiently. MCP is a standardized protocol that allows servers to expose data and functionality specifically tailored for interactions with large language models (LLMs). FastMCP handles the complex details of the MCP protocol and server management, letting developers focus on creating tools, resources, and prompts with minimal boilerplate code.

Key features of FastMCP include:

  • Creating MCP servers that expose data ("Resources") and functionality ("Tools") to LLMs.

  • Defining reusable interaction patterns through "Prompts."

  • Proxying and composing servers for complex applications.

  • Generating servers from OpenAPI specs or FastAPI objects.

  • Enterprise authentication options (Google, GitHub, Azure, Auth0, and more).

  • Deployment tools, client libraries, and testing utilities.

  • High-level, Pythonic API designed to accelerate development.

Typical usage involves decorating Python functions with @mcp.tool to expose them as callable tools in the MCP server environment, making it intuitive for Python developers. FastMCP 2.0 is actively maintained and considered the standard framework for developing production-grade MCP applications.

Example:

from fastmcp import FastMCP

# Create an MCP instance with a name
mcp = FastMCP("Demo")

# Define a tool that adds two numbers
@mcp.tool
def add(a: int, b: int) -> int:
    """Add two numbers"""
    return a + b

# Run the MCP server
if __name__ == "__main__":
    mcp.run()

This framework is ideal for building servers that integrate with AI applications by providing standardized, secure, and efficient endpoints designed specifically for LLMs.

Will I also be creating MCP Client with FastMCP?

Yes, with FastMCP, you can also create MCP clients in addition to servers. FastMCP provides a built-in Client class that lets you interact programmatically with any MCP server. This client handles all the connection management and MCP protocol details automatically, allowing deterministic and controlled operations such as calling tools, listing available resources, and sending requests. The client supports various transport mechanisms, including in-memory servers (useful for testing), HTTP servers, and local Python scripts. It is designed for explicit function calls rather than autonomous agent behavior, making it ideal for testing MCP servers and building reliable applications. Example usage of the FastMCP client:

Example:

import asyncio
from fastmcp import Client

async def main():
    # Connect to the MCP server
    async with Client("https://example.com/mcp") as client:
        # List available tools
        tools = await client.list_tools()
        print(f"Available tools: {tools}")

        # Call the "add" tool with arguments
        result = await client.call_tool("add", {"a": 5, "b": 3})

        # The result comes back as structured content
        print(f"Result: {result.content[0].text}")

# Run the async main function
asyncio.run(main())

How it works

  • Client("https://example.com/mcp") → Connects to your MCP server (That we created above. You need to give the MCP Server URL along with the port number on which the MCP server is running)

  • list_tools() → Queries the server for all registered tools (like add).

  • call_tool("add", {"a": 5, "b": 3}) → Calls the add tool with arguments a=5 and b=3.

  • result.content[0].text → Extracts the returned text from the tool’s response.

MCP - Model Context Protocol Series

Part 1 of 2

How AI agents never forget your files or lose context across tools? Meet Model Context Protocol (MCP). This deep dive covers what it is, full architecture, real projects & clever tricks going from zero to pro. Diagrams + code included. Let’s go!!

Up next

All About MCP Resource

What is a MCP Resource? How it is related to MCP Tooling? An MCP Resource is a read-only, addressable content entity exposed by the MCP server. Resources provide structured, contextual data that MCP clients can retrieve and deliver to LLMs for reason...

More from this blog