Skip to main content

Framework for building MCP servers

Project description

Golf Banner

Golf

Easiest framework for building MCP servers.

License PRs Support

Docs

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). The dev command includes hot reloading, so changes to your component files will automatically restart the server.

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)

Key aspects of your Golf server are configured in golf.json. The boilerplate provides a starting point like this:

{
  "name": "{{project_name}}",          // Will be replaced with your project name
  "description": "A Golf project", // A default description
  "host": "127.0.0.1",               // Server host address
  "port": 3000,                      // Server port
  "transport": "sse",                // 'sse', 'streamable-http', or 'stdio'
  "opentelemetry_enabled": false,    // OpenTelemetry disabled by default - we're working on this as a feature
  "opentelemetry_default_exporter": "console"
}

Roadmap

We are actively developing Golf. Here's what's on our current roadmap:

Documentation

For more information, please visit our official documentation:

https://docs.golf.dev

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.2.tar.gz (155.9 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.2-py3-none-any.whl (64.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: golf_mcp-0.1.2.tar.gz
  • Upload date:
  • Size: 155.9 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.2.tar.gz
Algorithm Hash digest
SHA256 920a416097a5cdff25e0aa8cc0dd0e9fa925dd04eb7ba1cd253ef1393d5258fb
MD5 749ff263aa79fdc7510cf0dd415bf946
BLAKE2b-256 8381b0cebeff1949dd476485b0a92c49042914d75c4a5bcea003e70aaff4cf91

See more details on using hashes here.

File details

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

File metadata

  • Download URL: golf_mcp-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 64.3 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 356e5c82d4e95ae32efc534d94ab21572f0f8a08de3bac17d23b8f8edf26ae10
MD5 2422202e28cbcecc1995a876498bd7a1
BLAKE2b-256 0a08f66c54def9121a1b805febd9cee51bc2873444189cd635fb4681ac5e43c0

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