Get started with your first GolfMCP project from scratch.
Let’s get you started with your first GolfMCP project from scratch.
Install GolfMCP
Install the Golf MCP framework using pip:
Initialize your project
Create a new GolfMCP project using the init
command:
This will create a new directory named my_awesome_server
with the following structure:
golf.json
: Configures your server’s name, port, transport, etc..env
: Stores environment-specific variables (automatically created).tools/
, resources/
, prompts/
: Directories where you’ll define your server’s capabilities.pre_build.py
: An optional script for custom logic before building, often used for authentication setup.Set up authentication
The boilerplate example includes a GitHub user tool that requires authentication. You can choose between two authentication methods:
Create a GitHub OAuth App by following GitHub’s OAuth App creation guide
Configure the OAuth App URLs (for local testing):
http://127.0.0.1:3000
http://127.0.0.1:3000/auth/callback
Set up environment variables in your .env
file:
Replace the values above with your actual GitHub OAuth app credentials.
Access the token in your tools using:
Create a GitHub OAuth App by following GitHub’s OAuth App creation guide
Configure the OAuth App URLs (for local testing):
http://127.0.0.1:3000
http://127.0.0.1:3000/auth/callback
Set up environment variables in your .env
file:
Replace the values above with your actual GitHub OAuth app credentials.
Access the token in your tools using:
Create a GitHub Personal Access Token from your GitHub settings
Configure API key authentication in pre_build.py
:
Pass the token when connecting your MCP client (see Step 7 for client configuration)
Access the API key in your tools using:
Create your first tool
Let’s modify the example “hello” tool. Open tools/hello.py
:
Key points about this tool:
Annotated
with Field
to provide descriptions for each parameter. This helps AI agents understand how to use your tool effectively.Output
class defines the structure of the response using Pydantic.export = hello
line tells Golf which function to expose as the tool.Build for development
Compile your project for development:
This command:
dist/
directory containing the runnable server (server.py
) and any necessary supporting files (like auth components).dev
builds, it copies your .env
file to the dist/
directory, making environment variables available to the server.Run your server
Execute the built server:
Congratulations! You’ve built and run your first GolfMCP server.
Connect to Claude or Cursor
To use your GolfMCP server with client like Claude Desktop, Cursor, Windsurf or any other client we recommend mcp-remote to SSE server.
Edit your Claude Desktop configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
Add your server configuration:
With API key authentication:
Edit your Claude Desktop configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
Add your server configuration:
With API key authentication:
Edit your Cursor configuration file at ~/.cursor/mcp.json
:
With API key authentication:
Troubleshooting authentication errors
If you encounter authentication errors like:
Clear any locally stored state and tokens:
Then restart your MCP client and try connecting again.