Golf
Easiest framework for building MCP servers with automatic discovery of tools, prompts, and resources, plus enterprise-grade authentication and telemetry.
README
<div align="center"> <img src="./golf-banner.png" alt="Golf Banner">
<br>
<h1 align="center"> <br> <span style="font-size: 80px;">β³ Golf</span> <br> </h1>
<h3 align="center"> Easiest framework for building MCP servers </h3>
<br>
<p> <a href="https://opensource.org/licenses/Apache-2.0"><img src="https://img.shields.io/badge/License-Apache%202.0-blue.svg" alt="License"></a> <a href="https://github.com/golf-mcp/golf/pulls"><img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg" alt="PRs"></a> <a href="https://github.com/golf-mcp/golf/issues"><img src="https://img.shields.io/badge/support-contact%20author-purple.svg" alt="Support"></a> </p>
<p> <a href="https://docs.golf.dev"><strong>π Documentation</strong></a> </p> </div>
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 MCP server, minimizing boilerplate and accelerating development.
With Golf v0.2.0, you get enterprise-grade authentication (JWT, OAuth Server, API key, development tokens), built-in utilities for LLM interactions, and automatic telemetry integration. Focus on implementing your agent's logic while Golf handles authentication, monitoring, and server infrastructure.
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 MCP server, typically on http://localhost: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)
ββ auth.py # Authentication configuration (JWT, OAuth Server, API key, dev tokens)
golf.json: Configures server name, port, transport, telemetry, and other build settings.auth.py: Dedicated authentication configuration file (new in v0.2.0, breaking change from v0.1.x authentication API) for JWT, OAuth Server, API key, or development authentication.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.pybecomeshello, and a nested file liketools/payments/submit.pywould becomesubmit_payments(filename, followed by reversed parent directories under the main category, joined by underscores).
- Component IDs are automatically derived from their file path. For example,
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 typing import Annotated
from pydantic import BaseModel, Field
class Output(BaseModel):
"""Response from the hello tool."""
message: str
async def hello(
name: Annotated[str, Field(description="The name of the person to greet")] = "World",
greeting: Annotated[str, Field(description="The greeting phrase to use")] = "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.
Authentication & Features
Golf includes enterprise-grade authentication, built-in utilities, and automatic telemetry:
# auth.py - Configure authentication
from golf.auth import configure_auth, JWTAuthConfig, StaticTokenConfig, OAuthServerConfig
# JWT authentication (production)
configure_auth(JWTAuthConfig(
jwks_uri_env_var="JWKS_URI",
issuer_env_var="JWT_ISSUER",
audience_env_var="JWT_AUDIENCE",
required_scopes=["read", "write"]
))
# OAuth Server mode (Golf acts as OAuth 2.0 server)
# configure_auth(OAuthServerConfig(
# base_url="https://your-golf-server.com",
# valid_scopes=["read", "write", "admin"]
# ))
# Static tokens (development only)
# configure_auth(StaticTokenConfig(
# tokens={"dev-token": {"client_id": "dev", "scopes": ["read"]}}
# ))
# Built-in utilities available in all tools
from golf.utils import elicit, sample, get_context
# Enable OpenTelemetry tracing
export OTEL_TRACES_EXPORTER="otlp_http"
export OTEL_EXPORTER_OTLP_ENDPOINT="http://localhost:4318/v1/traces"
golf run # β
Telemetry enabled
π Complete Documentation β
Configuration
Basic configuration in golf.json:
{
"name": "My Golf Server",
"host": "localhost",
"port": 3000,
"transport": "sse",
"opentelemetry_enabled": false,
"detailed_tracing": false
}
transport: Choose"sse","streamable-http", or"stdio"opentelemetry_enabled: Enable OpenTelemetry tracingdetailed_tracing: Capture input/output (use carefully with sensitive data)
Privacy & Telemetry
Golf collects anonymous usage data on the CLI 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:
-
Using the telemetry command (recommended):
golf telemetry disableThis saves your preference permanently. To re-enable:
golf telemetry enable -
During any command: Add
--no-telemetryto save your preference:golf init my-project --no-telemetry
Your telemetry preference is stored in ~/.golf/telemetry.json and persists across all Golf commands.
<div align="center"> Made with β€οΈ in Warsaw, Poland and SF </div>
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.