OI-OS/freshbooks-mcp-server
If you are the rightful owner of freshbooks-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
The FreshBooks MCP Server is designed to integrate FreshBooks with GenAI applications using the Model Context Protocol.
FreshBooks MCP Server
⚠️ For AI Agents: This repository includes an file with comprehensive installation and configuration instructions specifically designed for AI agents installing this server in OI OS (Brain Trust 4) environments. Please refer to for step-by-step setup instructions, intent mappings, parameter rules, and troubleshooting guidance.
A Model Context Protocol (MCP) server for integrating FreshBooks with GenAI applications.
Overview
Small business accounting software
Features
- Comprehensive FreshBooks API coverage
- Multiple authentication methods
- Enterprise-ready with rate limiting
- Full error handling and retry logic
- Async support for better performance
Prerequisites
- Python 3.8 or higher
- pip (Python package manager)
- FreshBooks account with API access
Installation
Install from Source
- Clone this repository:
git clone https://github.com/OI-OS/freshbooks-mcp-server.git
cd freshbooks-mcp-server
- Install dependencies:
pip install -e .
Or install dependencies directly:
pip install httpx pydantic pydantic-settings python-dotenv mcp
- Copy
.env.exampleto.env:
cp .env.example .env
- Configure your FreshBooks credentials in
.env:FRESHBOOKS_API_TOKEN- Your FreshBooks API token (for simple authentication)FRESHBOOKS_BUSINESS_ID- Your FreshBooks business ID (for simple authentication)FRESHBOOKS_CLIENT_ID- Your OAuth client ID (for OAuth authentication)FRESHBOOKS_CLIENT_SECRET- Your OAuth client secret (for OAuth authentication)
Note: Never commit your .env file or token files to version control. They are already excluded in .gitignore.
AI Installation Guide (OI OS / Brain Trust 4)
This section provides step-by-step instructions for AI assistants to install and configure the FreshBooks MCP server in OI OS environments.
Step 1: Install via OI Command
./oi install https://github.com/OI-OS/freshbooks-mcp-server.git
The installation will:
- Clone the repository to
MCP-servers/freshbooks-mcp-server/ - Install Python dependencies
- Auto-detect the server type
Step 2: Build and Install Dependencies
cd MCP-servers/freshbooks-mcp-server
pip3 install -e .
Step 3: Configure OAuth Credentials
Add the following to your project root .env file:
# FreshBooks OAuth Configuration
FRESHBOOKS_CLIENT_ID=your_client_id_here
FRESHBOOKS_CLIENT_SECRET=your_client_secret_here
FRESHBOOKS_REDIRECT_URI=https://localhost:8080/callback
# FreshBooks Account Information (obtained after authentication)
FRESHBOOKS_ACCOUNT_ID=your_account_id_here
FRESHBOOKS_BUSINESS_ID=your_business_id_here
FRESHBOOKS_BUSINESS_NAME=your_business_name
FRESHBOOKS_USER_EMAIL=your_email@example.com
FRESHBOOKS_USER_NAME=Your Name
Step 4: Connect the Server
Connect the OAuth server variant:
export FRESHBOOKS_CLIENT_ID=your_client_id_here
export FRESHBOOKS_CLIENT_SECRET=your_client_secret_here
export FRESHBOOKS_REDIRECT_URI=https://localhost:8080/callback
./brain-trust4 connect freshbooks-mcp-server python3 ./MCP-servers/freshbooks-mcp-server/src/freshbooks_mcp/simple_oauth_server.py
Step 5: Authenticate (First Time)
The OAuth flow requires manual browser interaction. Two methods:
Method A: Automatic Authentication (Interactive)
./brain-trust4 call freshbooks-mcp-server authenticate '{}'
This will:
- Open a browser for OAuth authorization
- Wait for user to complete authorization
- Exchange authorization code for access token
- Save token to
~/.freshbooks_token
Note: This command may timeout if run non-interactively. Use Method B for automation.
Method B: Manual Token Exchange
-
Get Authorization URL:
# Manually construct or trigger OAuth URL # URL format: https://auth.freshbooks.com/oauth/authorize?response_type=code&client_id=YOUR_CLIENT_ID&redirect_uri=https://localhost:8080/callback -
User completes authorization in browser and receives authorization code
-
Exchange code for access token:
export FRESHBOOKS_CLIENT_ID=your_client_id_here export FRESHBOOKS_CLIENT_SECRET=your_client_secret_here export FRESHBOOKS_REDIRECT_URI=https://localhost:8080/callback python3 -c " import asyncio import httpx import json import os import time async def exchange_code(): client_id = os.getenv('FRESHBOOKS_CLIENT_ID') client_secret = os.getenv('FRESHBOOKS_CLIENT_SECRET') redirect_uri = os.getenv('FRESHBOOKS_REDIRECT_URI') auth_code = 'AUTHORIZATION_CODE_FROM_USER' # Replace with actual code async with httpx.AsyncClient() as client: response = await client.post( 'https://api.freshbooks.com/auth/oauth/token', data={ 'grant_type': 'authorization_code', 'client_id': client_id, 'client_secret': client_secret, 'redirect_uri': redirect_uri, 'code': auth_code }, headers={'Content-Type': 'application/x-www-form-urlencoded'} ) result = response.json() print('Access Token:', result['access_token']) print('Account ID:', result['account_id']) print('Business ID:', result['business_id']) return result result = asyncio.run(exchange_code()) " -
Save token to
~/.freshbooks_token:python3 -c " import json import time import os token_data = { 'access_token': 'ACCESS_TOKEN_FROM_STEP_3', 'account_id': 'ACCOUNT_ID_FROM_STEP_3', 'business_id': 'BUSINESS_ID_FROM_STEP_3', 'timestamp': time.time() } token_file = os.path.expanduser('~/.freshbooks_token') with open(token_file, 'w') as f: json.dump(token_data, f) print('✅ Token saved to', token_file) " -
Optional: Save as FRESHBOOKS_API_TOKEN
The OAuth access token can also be used as
FRESHBOOKS_API_TOKENfor the standard server. Add to.env:FRESHBOOKS_API_TOKEN=your_oauth_access_token_here FRESHBOOKS_BUSINESS_ID=your_business_id_hereImportant: OAuth tokens expire in ~12 hours. The OAuth server automatically handles token refresh, while the standard server will need manual token updates.
Step 6: Verify Installation
Test the connection:
./oi "get freshbooks clients"
Or directly:
./brain-trust4 call freshbooks-mcp-server get_clients '{}'
Troubleshooting for AI Installations
- "Not authenticated" error: Run authentication flow (Step 5)
- Token expired: Re-authenticate or use OAuth server which auto-refreshes
- Environment variables not found: Export them before connecting server, or add to
.envand source it - Module not found: Ensure
pip3 install -e .completed successfully in the server directory
Quick Reference Commands
# Install
./oi install https://github.com/OI-OS/freshbooks-mcp-server.git
# Connect OAuth server
export FRESHBOOKS_CLIENT_ID=... FRESHBOOKS_CLIENT_SECRET=... FRESHBOOKS_REDIRECT_URI=...
./brain-trust4 connect freshbooks-mcp-server python3 ./MCP-servers/freshbooks-mcp-server/src/freshbooks_mcp/simple_oauth_server.py
# Connect standard server (if you have API token)
./brain-trust4 connect freshbooks-api python3 ./MCP-servers/freshbooks-mcp-server/src/freshbooks_mcp/server.py
# Test
./oi "get freshbooks clients"
Configuration for AI Clients
Using with Cursor
-
Open Cursor settings
-
Navigate to Features → Model Context Protocol
-
Click Edit Config or manually edit your MCP settings file:
- macOS/Linux:
~/.cursor/mcp.jsonor project-level.cursor/mcp.json - Windows:
%APPDATA%\Cursor\mcp.jsonor project-level.cursor\mcp.json
- macOS/Linux:
-
Add the FreshBooks MCP server configuration:
{
"mcpServers": {
"freshbooks": {
"command": "python3",
"args": ["/absolute/path/to/freshbooks-mcp-server/src/freshbooks_mcp/server.py"],
"env": {
"FRESHBOOKS_API_TOKEN": "your_freshbooks_api_token_here",
"FRESHBOOKS_BUSINESS_ID": "your_business_id_here"
}
}
}
}
For OAuth authentication, use:
{
"mcpServers": {
"freshbooks-oauth": {
"command": "python3",
"args": ["/absolute/path/to/freshbooks-mcp-server/src/freshbooks_mcp/simple_oauth_server.py"],
"env": {
"FRESHBOOKS_CLIENT_ID": "your_oauth_client_id_here",
"FRESHBOOKS_CLIENT_SECRET": "your_oauth_client_secret_here"
}
}
}
}
Alternative: Using project-level configuration
Create .cursor/mcp.json in your project root:
{
"mcpServers": {
"freshbooks": {
"command": "python3",
"args": ["./MCP-servers/freshbooks-mcp-server/src/freshbooks_mcp/server.py"],
"env": {
"FRESHBOOKS_API_TOKEN": "${FRESHBOOKS_API_TOKEN}",
"FRESHBOOKS_BUSINESS_ID": "${FRESHBOOKS_BUSINESS_ID}"
}
}
}
}
- Restart Cursor to apply changes
Using with Claude Desktop
-
Locate your Claude Desktop configuration file:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json - Linux:
~/.config/claude/claude_desktop_config.json
- macOS:
-
Edit the configuration file and add:
{
"mcpServers": {
"freshbooks": {
"command": "python3",
"args": ["/absolute/path/to/freshbooks-mcp-server/src/freshbooks_mcp/server.py"],
"env": {
"FRESHBOOKS_API_TOKEN": "your_freshbooks_api_token_here",
"FRESHBOOKS_BUSINESS_ID": "your_business_id_here"
}
}
}
}
- Save the file and restart Claude Desktop
Using with VS Code (with MCP Extension)
- Install an MCP extension for VS Code (if available)
- Create or edit
.vscode/mcp.jsonin your project:
{
"servers": {
"freshbooks": {
"command": "python3",
"args": ["/absolute/path/to/freshbooks-mcp-server/src/freshbooks_mcp/server.py"],
"env": {
"FRESHBOOKS_API_TOKEN": "your_freshbooks_api_token_here",
"FRESHBOOKS_BUSINESS_ID": "your_business_id_here"
},
"type": "stdio"
}
}
}
Using with Continue.dev
-
Open your Continue.dev configuration file:
- Location:
~/.continue/config.json(or%USERPROFILE%\.continue\config.jsonon Windows)
- Location:
-
Add to the
mcpServersarray:
{
"mcpServers": [
{
"name": "freshbooks",
"command": "python3",
"args": ["/absolute/path/to/freshbooks-mcp-server/src/freshbooks_mcp/server.py"],
"env": {
"FRESHBOOKS_API_TOKEN": "your_freshbooks_api_token_here",
"FRESHBOOKS_BUSINESS_ID": "your_business_id_here"
}
}
]
}
- Restart Continue.dev
Server Variants
This repository includes multiple server implementations:
- Standard Server (
src/freshbooks_mcp/server.py) - Uses MCP SDK with simple API token authentication - OAuth Server (
src/freshbooks_mcp/oauth_server.py) - Full OAuth flow with token refresh - Simple OAuth Server (
src/freshbooks_mcp/simple_oauth_server.py) - Simplified OAuth with interactive authentication - Raw MCP Server (
mcp_server.py) - Direct MCP protocol implementation - Simple Server (
simple_server.py) - Minimal implementation for testing
Choose the server that best fits your authentication needs.
Quick Start
To test the server manually:
# Using the standard server
python3 src/freshbooks_mcp/server.py
# Or using the run script
python3 run_server.py
The server communicates via stdio (standard input/output) for MCP protocol.
Available Tools
Once configured, the following FreshBooks tools will be available to your AI assistant:
Read Operations
get_clients- Get all clients from your FreshBooks accountget_invoices- Retrieve all invoicesget_projects- Get all projectsget_expenses- Retrieve all expensesget_time_entries- Get all time tracking entries
Write Operations (OAuth Server Only)
create_client- Create a new client in FreshBookscreate_invoice- Create a new invoicecreate_project- Create a new project
OAuth-Specific Tools (OAuth Server)
authenticate- Start the OAuth authentication flow (opens browser for authorization)
Troubleshooting
Server Not Appearing in Cursor/Claude
-
Check Python path: Ensure
python3is in your PATH. Test with:which python3 # macOS/Linux where python3 # Windows -
Verify absolute paths: Use absolute paths in your MCP configuration. Relative paths may not work.
-
Check environment variables: Ensure your FreshBooks credentials are correctly set in the
envsection of your MCP configuration. -
Restart the client: After making configuration changes, fully restart Cursor, Claude Desktop, or your AI client.
-
Check logs: Look for error messages in:
- Cursor: View → Output → select "Model Context Protocol"
- Claude Desktop: Check application logs
Authentication Issues
- API Token: Ensure your
FRESHBOOKS_API_TOKENis valid and has proper permissions - Business ID: Verify your
FRESHBOOKS_BUSINESS_IDmatches your FreshBooks account - OAuth: For OAuth servers, ensure your
FRESHBOOKS_CLIENT_IDandFRESHBOOKS_CLIENT_SECRETare correct
Python Module Not Found
If you get "ModuleNotFoundError", install dependencies:
cd /path/to/freshbooks-mcp-server
pip install -e .
Getting FreshBooks API Credentials
-
API Token Authentication:
- Log in to your FreshBooks account
- Go to Settings → Integrations → API
- Generate an API token
- Note your Business/Account ID
-
OAuth Authentication:
- Visit FreshBooks Developer Portal
- Create a new OAuth application
- Set redirect URI:
https://localhost:8080/callback - Copy Client ID and Client Secret
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
MIT License - see LICENSE file for details