Skip to main content

Framework for building MCP servers

Project description

Golf Banner


⛳ Golf

Easiest framework for building MCP servers


License PRs Support

📚 Documentation

Overview

Golf is a framework designed to streamline the creation of MCP server applications. It allows developers to define server's capabilities—tools, prompts, and resources—as simple Python files within a conventional directory structure. Golf then automatically discovers, parses, and compiles these components into a runnable FastMCP server, minimizing boilerplate and accelerating development.

With Golf, you can focus on implementing your agent's logic rather than wrestling with server setup and integration complexities. It's built for developers who want a quick, organized way to build powerful MCP servers.

Quick Start

Get your Golf project up and running in a few simple steps:

1. Install Golf

Ensure you have Python (3.10+ recommended) installed. Then, install Golf using pip:

pip install golf-mcp

2. Initialize Your Project

Use the Golf CLI to scaffold a new project:

golf init your-project-name

This command creates a new directory (your-project-name) with a basic project structure, including example tools, resources, and a golf.json configuration file.

3. Run the Development Server

Navigate into your new project directory and start the development server:

cd your-project-name
golf build dev
golf run

This will start the FastMCP server, typically on http://127.0.0.1:3000 (configurable in golf.json).

That's it! Your Golf server is running and ready for integration.

Basic Project Structure

A Golf project initialized with golf init will have a structure similar to this:

<your-project-name>/
│
├─ golf.json          # Main project configuration
│
├─ tools/             # Directory for tool implementations
│   └─ hello.py       # Example tool
│
├─ resources/         # Directory for resource implementations
│   └─ info.py        # Example resource
│
├─ prompts/           # Directory for prompt templates
│   └─ welcome.py     # Example prompt
│
├─ .env               # Environment variables (e.g., API keys, server port)
└─ pre_build.py       # (Optional) Script for pre-build hooks (e.g., auth setup)
  • golf.json: Configures server name, port, transport, telemetry, and other build settings.
  • tools/, resources/, prompts/: Contain your Python files, each defining a single component. These directories can also contain nested subdirectories to further organize your components (e.g., tools/payments/charge.py). The module docstring of each file serves as the component's description.
    • Component IDs are automatically derived from their file path. For example, tools/hello.py becomes hello, and a nested file like tools/payments/submit.py would become submit-payments (filename, followed by reversed parent directories under the main category, joined by hyphens).
  • common.py (not shown, but can be placed in subdirectories like tools/payments/common.py): Used to share code (clients, models, etc.) among components in the same subdirectory.

Example: Defining a Tool

Creating a new tool is as simple as adding a Python file to the tools/ directory. The example tools/hello.py in the boilerplate looks like this:

# tools/hello.py
"""Hello World tool {{project_name}}."""

from pydantic import BaseModel

class Output(BaseModel):
    """Response from the hello tool."""
    message: str

async def hello(
    name: str = "World",
    greeting: str = "Hello"
) -> Output:
    """Say hello to the given name.
    
    This is a simple example tool that demonstrates the basic structure
    of a tool implementation in Golf.
    """
    print(f"{greeting} {name}...")
    return Output(message=f"{greeting}, {name}!")

# Designate the entry point function
export = hello

Golf will automatically discover this file. The module docstring """Hello World tool {{project_name}}.""" is used as the tool's description. It infers parameters from the hello function's signature and uses the Output Pydantic model for the output schema. The tool will be registered with the ID hello.

Configuration (golf.json)

The golf.json file is the heart of your Golf project configuration. Here's what each field controls:

{
  "name": "{{project_name}}",          // Your MCP server name (required)
  "description": "A Golf project",     // Brief description of your server's purpose
  "host": "127.0.0.1",                // Server host - use "0.0.0.0" to listen on all interfaces
  "port": 3000,                       // Server port - any available port number
  "transport": "sse",                 // Communication protocol:
                                      // - "sse": Server-Sent Events (recommended for web clients)
                                      // - "streamable-http": HTTP with streaming support
                                      // - "stdio": Standard I/O (for CLI integration)
}

Key Configuration Options:

  • name: The identifier for your MCP server. This will be shown to clients connecting to your server.
  • transport: Choose based on your client needs:
    • "sse" is ideal for web-based clients and real-time communication
    • "streamable-http" provides HTTP streaming for traditional API clients
    • "stdio" enables integration with command-line tools and scripts
  • host & port: Control where your server listens. Use "127.0.0.1" for local development or "0.0.0.0" to accept external connections.

Privacy & Telemetry

Golf collects anonymous usage data to help us understand how the framework is being used and improve it over time. The data collected includes:

  • Commands run (init, build, run)
  • Success/failure status (no error details)
  • Golf version, Python version (major.minor only), and OS type
  • Template name (for init command only)
  • Build environment (dev/prod for build commands only)

No personal information, project names, code content, or error messages are ever collected.

Opting Out

You can disable telemetry in several ways:

  1. Using the telemetry command (recommended):

    golf telemetry disable
    

    This saves your preference permanently. To re-enable:

    golf telemetry enable
    
  2. During any command: Add --no-telemetry to save your preference:

    golf init my-project --no-telemetry
    
  3. Environment variable (temporary override):

    export GOLF_TELEMETRY=0
    golf init my-project
    

Your telemetry preference is stored in ~/.golf/telemetry.json and persists across all Golf commands.

Roadmap

Here are the things we are working hard on:

  • Native OpenTelemetry implementation for tracing
  • golf deploy command for one click deployments to Vercel, Blaxel and other providers
  • Production-ready OAuth token management, to allow for persistent, encrypted token storage and client mapping
Made with ❤️ in Warsaw, Poland and SF

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

golf_mcp-0.1.3.tar.gz (159.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

golf_mcp-0.1.3-py3-none-any.whl (67.9 kB view details)

Uploaded Python 3

File details

Details for the file golf_mcp-0.1.3.tar.gz.

File metadata

  • Download URL: golf_mcp-0.1.3.tar.gz
  • Upload date:
  • Size: 159.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.6

File hashes

Hashes for golf_mcp-0.1.3.tar.gz
Algorithm Hash digest
SHA256 90d8f4177ff1292c9b9a58a65d38dc70ec561e393845d1b37611b540769baf39
MD5 07b4040cfcca23f265be6beab4fdaa8f
BLAKE2b-256 c70569b49520852b52b735ccc3325a505012e22e828d179dde32bb6cf4895ffc

See more details on using hashes here.

File details

Details for the file golf_mcp-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: golf_mcp-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 67.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.6

File hashes

Hashes for golf_mcp-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ba80517f58bd12afa8bd4de5daa2ff30f153b53f227414ec2592753fc8ce39ee
MD5 d041b7b414db3167a04398d891aca5cc
BLAKE2b-256 9d798af4d5ab344f0e67af1754a70771300e24bf1b4500f9c4228cd0be4cc78f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page