MCP tool server for exposing Python functions as tools

MCP tool server for exposing Python functions as tools

mcp-server-planetf1•byplanetf1

An asynchronous MCP server built on FastMCP that serves built-in and dynamically loaded Python functions as tools over stdio or Server-Sent Events.

License: Not specified•Runtime: Awaiting documentation review•Category: developer tools

WHAT IT DOES

  • •Offers built-in echo and health tools that return their parameters and report server readiness.
  • •Dynamically loads Python functions as tools from specified .py files or directories of .py files.
  • •Supports both stdio and SSE transports, with stdio as the default.
  • •Provides DEBUG-level logging of tool calls and MCP SDK activity to a specified file.

BEST FOR

  • •Exposing custom Python functions such as a calculator to MCP clients.
  • •Loading a whole directory of Python tool modules behind one server.
  • •Serving tools to web clients over Server-Sent Events.

ABOUT MCP-SERVER-PLANETF1

MCP tool server for exposing Python functions as tools is cataloged as an MCP server attributed to planetf1. An asynchronous MCP server built on FastMCP that serves built-in and dynamically loaded Python functions as tools over stdio or Server-Sent Events. It is categorized under developer tools. See the capability inspector for recorded interfaces and their independent review status; consult upstream documentation for the current interface.

HOW TO INSTALL

Installation configuration is not reviewed. No executable setup is offered for this entry; inspect the source repository before proceeding.

LICENSE

Catalog license label: Not specified. Check the source repository's current license and terms before using, modifying or distributing this software.

Capability inspector

Capability definitions are not reviewed. Unreviewed imports are not exposed as trusted interfaces.

Tools (0)

No reviewed records to display. This does not establish that upstream lacks this capability.

Resources (0)

No reviewed records to display. This does not establish that upstream lacks this capability.

Prompts (0)

No reviewed records to display. This does not establish that upstream lacks this capability.

NEWSLETTER - COMING LATER

Newsletter subscriptions are not open yet

Email delivery is not connected. This page does not collect email addresses or create subscriptions.

Browse the registry for current listings instead.

Community Reviews

Coming later

Reviews for MCP tool server for exposing Python functions as tools are not available yet

Review publishing and storage are not connected. This page does not collect or publish ratings or comments, including after sign-in.

FREQUENTLY ASKED QUESTIONS

How many tools should each tool file define?

Each Python file intended as a tool module must define exactly one function, whose name becomes the tool name.

How can tool files use their own module imports?

The server temporarily adds the tool's directory to sys.path during loading so local imports work.

Upstream README

View this exact version on GitHub

README.md · 841e0616e93f · Fetched 2026-11-13 13:53:25 UTC

Original upstream text, without AI rewriting. Scripts, forms and unsafe links are filtered for safety.

Showing the last retrieved documentation snapshot; check the source for current changes.

MCP Tool Server (mcp_server.py)

The mcp_server.py script is an asynchronous server designed to expose Python functions as "tools" over various communication transports. It utilizes the FastMCP framework to manage tools and handle client interactions. The server comes with built-in tools and supports dynamic loading of custom tools from Python files or directories.

Features

  • Multiple Transports: Supports communication via:
    • stdio: Standard input/output, suitable for direct command-line interaction or integration with other processes.
    • sse: Server-Sent Events, allowing web clients to subscribe to tool outputs (listens on http://<host>:<port>/sse).
  • Built-in Tools:
    • echo: Returns the parameters it was called with.
    • health: Reports the server's operational status (returns "ready").
  • Custom Tool Loading:
    • Dynamically loads Python functions as tools from specified .py files or directories containing .py files.
    • Each tool file must define exactly one function to be exposed as a tool.
    • Imports within tool files are supported.
  • Configurable Logging:
    • Outputs INFO level messages to the console by default.
    • Supports detailed DEBUG level logging to a specified file for both the server application and the underlying MCP SDK.
  • Asynchronous: Built with asyncio for efficient handling of concurrent operations.

Prerequisites

  • Python 3.x
  • The mcp Python package (specifically mcp.server.fastmcp is used). Ensure this package is installed in your Python environment.

Command-Line Usage

Synopsis

python mcp_server.py [tools_paths...] [--log FILENAME] [--transport {stdio,sse}] [--port PORT]

Options

  • tools_paths (positional, zero or more)

    • Paths to Python tool files or directories containing Python tool files.
    • If a directory is provided, the server will search for *.py files (excluding those starting with _).
    • Example: ./my_tool.py ./utils_directory
    • Default: None (only built-in tools will be available if no paths are provided).
  • --log FILENAME

    • Enable detailed logging (DEBUG level for the application and MCP SDK) to the specified file.
    • Includes full details of tool calls, responses, and internal operations.
    • Console will still show INFO level messages.
  • --transport {stdio|sse}

    • Communication transport to use.
    • stdio: Use standard input/output.
    • sse: Use Server-Sent Events. The server will listen on 0.0.0.0 by default.
    • Default: stdio
  • --port PORT

    • Port number to use for the SSE transport.
    • Default: 8080

Tool Loading

Custom tools are Python functions that the server can expose.

  • Definition: Each Python file (.py) intended to be a tool module should define exactly one function. This function will be registered as a tool. The name of the function will be its tool name.
  • Discovery:
    • If a path to a .py file is provided, the server attempts to load the tool from that file.
    • If a path to a directory is provided, the server scans the directory for .py files (ignoring files like __init__.py or any file starting with an underscore) and attempts to load a tool from each valid file.
  • Imports: Tool files can import other modules as needed. The server temporarily adds the tool's directory to sys.path during loading to facilitate local imports.

Examples

1. Creating a Custom Tool

Create a Python file, for example, calculator.py:

# calculator.py
def add(a: int, b: int) -> int:
    """
    Adds two integers and returns the result.
    """
    print(f"Tool 'add' called with a={a}, b={b}") # Example of internal tool logging
    return a + b

2. Running the Server

a) With built-in tools only (stdio transport):

python mcp_server.py

The server will start, and you can interact with echo and health tools via its standard input/output (details depend on the FastMCP client interaction protocol).

b) With a custom tool (stdio transport):

python mcp_server.py calculator.py

Now, the add tool from calculator.py will also be available.

c) With a directory of tools and detailed logging (stdio transport):

Assuming you have a directory named my_tools containing calculator.py and other tool files:

mkdir my_tools
mv calculator.py my_tools/
# You can add more .py tool files to my_tools/

python mcp_server.py my_tools --log server.log

The server will load all valid tools from the my_tools directory. Detailed logs will be written to server.log, and INFO messages to the console.

d) Using SSE transport:

python mcp_server.py calculator.py --transport sse --port 8888

The server will start and listen for SSE connections on http://0.0.0.0:8888/sse. Clients can connect to this endpoint to interact with the echo, health, and add tools.

Interacting with the Server (Conceptual)

How you interact with the tools depends on the chosen transport and the FastMCP client-side implementation.

  • For stdio: You would typically send JSON-RPC like messages to the server's standard input and receive responses on its standard output.

    // Example conceptual input for stdio (actual format depends on FastMCP)
    // {"jsonrpc": "2.0", "method": "add", "params": {"a": 5, "b": 3}, "id": 1}
    
  • For sse: Clients would connect to the /sse endpoint. The server would then push messages for tool invocations and responses.

Logging

  • Console: By default, INFO level messages are printed to stdout. This includes server startup messages, registered tools, and basic activity.
  • File Logging (--log option):
    • Enables DEBUG level logging for both mcp_server.py and the mcp SDK.
    • This is highly verbose and includes:
      • Detailed tool invocation parameters and results.
      • Internal server operations.
      • Debug messages from the MCP SDK.
    • The log file is written in a format like: %(asctime)s - %(name)s - %(levelname)s - %(message)s.

Shutdown

Press Ctrl+C to shut down the server gracefully.

Install configuration

Are you the maintainer?

Claim this server with your GitHub account to request manual ownership verification.

README Embed Badge
Markdown

Link to the catalog listing for MCP tool server for exposing Python functions as tools from your README. This badge does not certify ownership, compatibility or security.

[![MCP catalog listing](https://img.shields.io/badge/MCP-awesome--mcp-orange?style=flat-square)](https://awesome-mcp.com/servers/mcp-server-planetf1)

REPOSITORY STATS

GitHub StarsUnavailable
ForksUnavailable

Public repository statistics could not be verified. Check the configured source address; unavailable counts are not zero.

Downloads and pulls

Separate sources, scopes and periods. Never combined or treated as installations, active users or security reviews.

No reviewed package or image identity; download statistics are not listed yet.

Related developer tools MCP Servers

Alternative and complementary servers in the same category

View all in developer tools →
Postbye
postbye-mcp•postbye-team

A directory listing describing a cancellation-letter and mailing-address service. The configured public GitHub repository returned 404 during source verification.

Repository stats unavailable
Developer Tools
Singapore Proxy MCP
singapore-proxy-mcp•Xavierfok

A hosted MCP service for browsing and searching through Singapore mobile-network proxies.

0
Developer Tools

A directory listing describing a Markdown-to-PDF service. The configured public GitHub repository returned 404 during source verification.

Repository stats unavailable
Developer Tools