Implementing Authentication in a Remote MCP Server with Python and FastMCP

Implementing Authentication in a Remote MCP Server with Python and FastMCP

A couple of months ago, I published the blog post Implementing Authentication in a Remote MCP Server with SSE Transport. That article demonstrated how to add authentication for remote MCP servers written in Go.

At the time, I also wanted to include Python examples. Unfortunately, things weren’t straightforward. The official Python MCP SDK didn’t provide a clean way to implement what I needed. There were some workarounds using Starlette middleware, but in my experience, those solutions were brittle and ultimately unsuccessful.

Later, I managed to create a working Python MCP server supporting SSE (or streaming HTTP) transport. But my solution relied on thread-level hacks to make the data thread-safe. It worked, but it felt like a fragile and inelegant design—something I wasn’t comfortable recommending or maintaining long-term.

Now, after revisiting the problem, I’ve found a much cleaner solution in Python. This time it’s not with the official Python MCP SDK, but with an alternative implementation called FastMCP. FastMCP is written in the spirit of the official SDK, offering a very similar syntax, but with additional features, clearer abstractions, and—importantly—excellent documentation.

Continue Reading ...

Building MCP Servers with Configurable Descriptions for Tools

Building MCP Servers with Configurable Descriptions for Tools

I want to share my findings on how to make MCP (Model Context Protocol) Server tools more responsive and adaptive to user needs by allowing configurable tool descriptions. This can significantly enhance the user experience by providing more relevant and context-aware descriptions for specific projects or tasks.

If you are not yet familiar with MCP, I recommend checking out the official documentation. In short, MCP is a protocol that allows different AI models and tools to communicate and work together seamlessly. In practice, MCP servers are small plugins for your AI agent or chat tool (for example, Claude Desktop) that provide specific functionalities, such as web browsing, code execution, or data retrieval.


MCP Tool Descriptions

Usually, an MCP server tool definition looks like this:

{
  "name": "get-webpage",
  "description": "A tool for retrieving the content of a webpage. It accepts a URL as input and returns the HTML content of the page.",
  "parameters": {
    "type": "object",
    "properties": {
      "url": {
        "type": "string",
        "description": "The URL of the webpage to visit."
      }
    },
    "required": ["url"]
  }
}
Continue Reading ...