prime-mcp-server
v1.0.0
Published
MCP server for Prime Ecosystem API - Insurance/Construction job management
Maintainers
Readme
Prime MCP Server
MCP (Model Context Protocol) server for the Prime Ecosystem API, providing AI assistants with access to insurance and construction job management functionality.
Features
- 40+ tools covering all major Prime API functionality
- Financial analysis tools for comparing estimates, work orders, and invoices
- Smart search by customer name or address with automatic pagination
- Rate limiting respects Prime's limits (60 req/min, 5000/day, 5 concurrent)
- Full JSON:API support with proper request/response handling
- Zod validation for all tool inputs
- TypeScript with full type safety
Available Tools
Job Management
prime_search_jobs- Search and filter jobs with paginationprime_search_jobs_by_address- Search jobs by street, suburb, state, or postcodeprime_search_jobs_by_customer- Search jobs by customer nameprime_get_job- Get detailed job information by IDprime_create_job- Create a new jobprime_update_job- Update job detailsprime_update_job_status- Change job status
Financial Analysis
prime_get_job_allocation_summary- Work order totals grouped by tradeprime_get_job_trade_comparison- Compare work orders vs authorized estimates by tradeprime_get_job_financial_summary- Full comparison: Estimates vs Work Orders vs AP Invoices with alerts
Contact Management
prime_search_contacts- Search contacts by name, email, phoneprime_get_contact- Get contact detailsprime_create_contact- Create new contact (individual or organization)prime_update_contact- Update contact information
Allocation Management
prime_list_allocations- List work allocationsprime_get_allocation- Get allocation detailsprime_create_allocation- Create work allocationprime_update_allocation- Update allocation
Estimate Management
prime_list_estimates- List estimates (locked or unlocked)prime_get_estimate- Get estimate with line itemsprime_create_estimate- Create new estimateprime_add_estimate_item- Add line item to estimateprime_update_estimate_item- Update estimate line itemprime_delete_estimate_item- Delete estimate line item
Schedule Management
prime_get_job_schedule- Get schedule for a jobprime_list_schedule_items- List schedule itemsprime_create_schedule_item- Create schedule itemprime_update_schedule_item- Update schedule itemprime_delete_schedule_item- Delete schedule item
Invoice Management
prime_list_ap_invoices- List accounts payable invoicesprime_get_ap_invoice- Get AP invoice detailsprime_create_ap_invoice- Create AP invoiceprime_update_ap_invoice- Update AP invoiceprime_update_ap_invoice_status- Update AP invoice statusprime_list_ar_invoices- List accounts receivable invoicesprime_get_ar_invoice- Get AR invoice detailsprime_update_ar_invoice_status- Update AR invoice status
Work Order Management
prime_list_work_orders- List work ordersprime_get_work_order- Get work order detailsprime_update_work_order- Update work order
Attachment Management
prime_list_attachments- List job attachmentsprime_get_attachment- Get attachment detailsprime_create_attachment- Create attachment recordprime_update_attachment- Update attachment metadata
Notification Management
prime_list_notifications- List sent notificationsprime_get_notification- Get notification detailsprime_create_notification- Send notificationprime_list_notification_templates- List available templatesprime_get_notification_template- Get template details
Reference Data
prime_list_job_statuses- List job statusesprime_get_job_status- Get status detailsprime_list_perils- List peril types (Fire, Flood, Storm, etc.)prime_list_trades- List trade types (Plumbing, Electrical, etc.)prime_list_divisions- List company divisionsprime_list_users- List system usersprime_get_user- Get user detailsprime_list_workflows- List workflowsprime_list_job_types- List job typesprime_list_allocation_statuses- List allocation statusesprime_list_filter_tags- List filter tagsprime_rate_limit_status- Check current rate limit status
Installation
# Clone the repository
git clone https://github.com/MikahDev/prime-mcp-server.git
cd prime-mcp-server
# Install dependencies
npm install
# Build
npm run buildConfiguration
Environment Variables
# Required: OAuth2 credentials
export PRIME_CLIENT_ID=your-client-id
export PRIME_CLIENT_SECRET=your-client-secret
export PRIME_USERNAME=your-username
export PRIME_PASSWORD=your-password
# Optional: Override API URLs (defaults to production)
export PRIME_API_URL=https://www.primeeco.tech/api.prime/v2
export PRIME_OAUTH_URL=https://www.primeeco.tech/api.prime/v2/oauth/token
# Optional: Log level (debug, info, warn, error)
export LOG_LEVEL=infoGetting OAuth2 Credentials
Contact your Prime administrator to obtain:
- Client ID - Your application's client identifier
- Client Secret - Your application's secret key
- Username - Your Prime user account
- Password - Your Prime password
The server uses OAuth2 password grant flow and automatically handles token refresh.
Usage
Quick Start with npx
# Run directly without installing
npx prime-mcp-serverWith Claude Desktop
Add to your Claude Desktop configuration (~/Library/Application Support/Claude/claude_desktop_config.json on macOS):
{
"mcpServers": {
"prime": {
"command": "npx",
"args": ["prime-mcp-server"],
"env": {
"PRIME_CLIENT_ID": "your-client-id",
"PRIME_CLIENT_SECRET": "your-client-secret",
"PRIME_USERNAME": "your-username",
"PRIME_PASSWORD": "your-password"
}
}
}
}Or with a local installation:
{
"mcpServers": {
"prime": {
"command": "node",
"args": ["/path/to/prime-mcp-server/dist/index.js"],
"env": {
"PRIME_CLIENT_ID": "your-client-id",
"PRIME_CLIENT_SECRET": "your-client-secret",
"PRIME_USERNAME": "your-username",
"PRIME_PASSWORD": "your-password"
}
}
}
}With ChatGPT (HTTP Mode)
The server supports Streamable HTTP transport for ChatGPT integration.
1. Start the HTTP server:
# Set credentials
export PRIME_CLIENT_ID=your-client-id
export PRIME_CLIENT_SECRET=your-client-secret
export PRIME_USERNAME=your-username
export PRIME_PASSWORD=your-password
# Start HTTP server (default port 3000)
npm run start:http
# Or with custom port
PORT=8080 npm run start:http2. Expose to the internet (for testing, use ngrok):
ngrok http 30003. Connect in ChatGPT:
- Go to ChatGPT → Settings → Connectors → Create
- Enter your public URL (e.g.,
https://abc123.ngrok.io/mcp) - The connector will auto-discover available tools
Note: ChatGPT MCP support requires a Pro, Plus, or Business account with Developer Mode enabled (Settings → Connectors → Advanced → Developer mode).
Standalone
# Set credentials
export PRIME_CLIENT_ID=your-client-id
export PRIME_CLIENT_SECRET=your-client-secret
export PRIME_USERNAME=your-username
export PRIME_PASSWORD=your-password
# Run stdio transport (for Claude)
npm start
# Run HTTP transport (for ChatGPT)
npm run start:httpDevelopment
# Run with hot reload
npm run dev
# Run tests
npm test
# Type check
npm run typecheckRate Limits
The Prime API has the following rate limits:
| Limit | Value | |-------|-------| | Per Minute | 60 requests | | Per Day | 5,000 requests | | Concurrent | 5 requests |
The MCP server automatically handles rate limiting:
- Tracks tokens and waits when approaching limits
- Updates from response headers for accuracy
- Queues concurrent requests exceeding the limit
- Provides
prime_rate_limit_statustool to check current status
Error Handling
All tools return consistent error responses:
{
"error": true,
"code": "VALIDATION_ERROR",
"message": "Description of the error",
"details": {
"field": "specific field error"
}
}Error codes:
RATE_LIMITED- Rate limit exceeded (includesretryAfter)UNAUTHORIZED- Invalid or missing API tokenFORBIDDEN- Permission deniedNOT_FOUND- Resource not foundVALIDATION_ERROR- Invalid input parametersSERVER_ERROR- Prime API server errorNETWORK_ERROR- Connection failedINTERNAL_ERROR- Unexpected error
Project Structure
prime-mcp-server/
├── src/
│ ├── index.ts # Entry point
│ ├── server.ts # MCP server setup
│ ├── client/
│ │ ├── prime-client.ts # HTTP client
│ │ ├── rate-limiter.ts # Rate limiting
│ │ └── json-api.ts # JSON:API utilities
│ ├── config/
│ │ └── index.ts # Configuration
│ ├── schemas/ # Zod validation schemas
│ ├── tools/ # MCP tool implementations
│ └── utils/
│ ├── error-handler.ts # Error formatting
│ └── filter-builder.ts # Query filter builder
├── tests/
│ └── unit/ # Unit tests
├── package.json
├── tsconfig.json
└── vitest.config.tsContributing
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests:
npm test - Submit a pull request
License
MIT
