Drop this into a file and run it:
from mcp.server.fastmcp import FastMCP import httpx
mcp = FastMCP ( " mini-tools " )
@mcp.tool () def read_file ( path : str ) -> str : """ Read the contents of a file. """ with open ( path ) as f : return f . read ()
@mcp.tool () async def fetch_url ( url : str ) -> str : """ Fetch a URL and return the response text. """ async with httpx . AsyncClient () as client : resp = await client . get ( url ) return resp . text
if __name__ == " __main__ " : mcp . run ()
Enter fullscreen mode
Exit fullscreen mode
Save as server.py , install the one dependency, and start it:
pip install mcp httpx python server.py
Enter fullscreen mode
Exit fullscreen mode
You now have an MCP server that gives any AI agent the ability to read files and fetch web pages. In 13 lines of code.
How the FastMCP API works
The mcp package ships two APIs. The older one uses @app.list_tools() and @app.call_tool() decorators that receive raw JSON.…