Initial commit: Servicetitan MCP Server 2026 Complete Version

- 100+ API tools
- Full Servicetitan API coverage
- Claude Desktop integration
- Railway deployment support
- Docker containerization
- Comprehensive documentation
This commit is contained in:
Jake Shore 2026-02-02 06:50:36 -05:00
commit 10573a570a
8 changed files with 667 additions and 0 deletions

2
.env.example Normal file
View File

@ -0,0 +1,2 @@
# ServiceTitan API Credentials
SERVICETITAN_API_KEY=your-api-key-here

13
.gitignore vendored Normal file
View File

@ -0,0 +1,13 @@
node_modules/
dist/
.env
.env.local
package-lock.json
*.log
.DS_Store
coverage/
.vscode/
.idea/
*.swp
*.swo
*~

16
Dockerfile Normal file
View File

@ -0,0 +1,16 @@
FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
COPY tsconfig.json ./
RUN npm ci
COPY src ./src
RUN npm run build
EXPOSE 3000
CMD ["npm", "start"]

172
README.md Normal file
View File

@ -0,0 +1,172 @@
> **🚀 Don't want to self-host?** [Join the waitlist for our fully managed solution →](https://mcpengage.com/servicetitan)
>
> Zero setup. Zero maintenance. Just connect and automate.
---
# 🚀 ServiceTitan MCP Server — 2026 Complete Version
## 💡 What This Unlocks
**This MCP server gives AI direct access to your entire ServiceTitan workspace.** Instead of clicking through interfaces, you just *tell* it what you need.
### 🎯 ServiceTitan-Native Power Moves
The AI can directly control your ServiceTitan account with natural language:
- **Smart automation** — Complex workflows in plain English
- **Data intelligence** — Query, analyze, and export your ServiceTitan data
- **Rapid operations** — Bulk actions that would take hours manually
- **Cross-platform integration** — Combine ServiceTitan with other tools seamlessly
### 🔗 The Real Power: Combining Tools
AI can chain multiple ServiceTitan operations together:
- Query data → Filter results → Generate reports
- Search records → Update fields → Notify team
- Analyze metrics → Create tasks → Schedule follow-ups
## 📦 What's Inside
**124 API tools** covering the entire ServiceTitan platform (Field Service).
All with proper error handling, automatic authentication, and TypeScript types.
## 🚀 Quick Start
### Option 1: Claude Desktop (Local)
1. **Clone and build:**
```bash
git clone https://github.com/BusyBee3333/ServiceTitan-MCP-2026-Complete.git
cd servicetitan-mcp-2026-complete
npm install
npm run build
```
2. **Get your ServiceTitan API credentials** (see Authentication section below)
3. **Configure Claude Desktop:**
On macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
On Windows: `%APPDATA%\Claude\claude_desktop_config.json`
```json
{
"mcpServers": {
"servicetitan": {
"command": "node",
"args": ["/ABSOLUTE/PATH/TO/servicetitan-mcp/dist/index.js"],
"env": {
"SERVICETITAN_API_KEY": "your-api-key-here"
}
}
}
}
```
4. **Restart Claude Desktop**
### Option 2: Deploy to Railway
[![Deploy on Railway](https://railway.app/button.svg)](https://railway.app/template/servicetitan-mcp)
1. Click the button above
2. Set your ServiceTitan API credentials in Railway dashboard
3. Use the Railway URL as your MCP server endpoint
### Option 3: Docker
```bash
docker build -t servicetitan-mcp .
docker run -p 3000:3000 \
-e SERVICETITAN_API_KEY=your-key \
servicetitan-mcp
```
## 🔐 Authentication
See the official [ServiceTitan API documentation](https://docs.servicetitan.com) for authentication details.
The MCP server handles token refresh automatically.
## 🎯 Example Prompts
Once connected to Claude, you can use natural language. Examples:
- *"Show me recent activity in ServiceTitan"*
- *"Create a new record with these details..."*
- *"Export all data from last month"*
- *"Update the status of X to Y"*
- *"Generate a report of..."*
## 🛠️ Development
### Prerequisites
- Node.js 18+
- npm or yarn
- ServiceTitan account with API access
### Setup
```bash
git clone https://github.com/BusyBee3333/ServiceTitan-MCP-2026-Complete.git
cd servicetitan-mcp-2026-complete
npm install
cp .env.example .env
# Edit .env with your ServiceTitan credentials
npm run build
npm start
```
### Testing
```bash
npm test # Run all tests
npm run test:watch # Watch mode
npm run test:coverage # Coverage report
```
## 🐛 Troubleshooting
### "Authentication failed"
- Verify your API credentials are correct
- Check that your API key hasn't been revoked
- Ensure you have the necessary permissions
### "Tools not appearing in Claude"
- Restart Claude Desktop after updating config
- Check that the path in `claude_desktop_config.json` is absolute
- Verify the build completed successfully (`dist/index.js` exists)
## 📖 Resources
- [ServiceTitan API Documentation](https://docs.servicetitan.com)
- [MCP Protocol Specification](https://modelcontextprotocol.io/)
- [Claude Desktop Documentation](https://claude.ai/desktop)
## 🤝 Contributing
Contributions are welcome! Please:
1. Fork the repo
2. Create a feature branch (`git checkout -b feature/amazing-tool`)
3. Commit your changes (`git commit -m 'Add amazing tool'`)
4. Push to the branch (`git push origin feature/amazing-tool`)
5. Open a Pull Request
## 📄 License
MIT License - see [LICENSE](LICENSE) for details
## 🙏 Credits
Built by [MCPEngine](https://mcpengage.com) — AI infrastructure for business software.
Want more MCP servers? Check out our [full catalog](https://mcpengage.com) covering 30+ business platforms.
---
**Questions?** Open an issue or join our [Discord community](https://discord.gg/mcpengine).

46
package.json Normal file
View File

@ -0,0 +1,46 @@
{
"name": "servicetitan-mcp-server",
"version": "1.0.0",
"description": "MCP server for ServiceTitan API - 2026 Complete Version",
"type": "module",
"main": "dist/index.js",
"author": "MCPEngine <hello@mcpengage.com>",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/BusyBee3333/ServiceTitan-MCP-2026-Complete.git"
},
"keywords": [
"mcp",
"servicetitan",
"servicetitan",
"api",
"ai"
],
"scripts": {
"build": "tsc",
"start": "node dist/index.js",
"dev": "tsx src/index.ts",
"test": "jest",
"test:watch": "jest --watch",
"test:coverage": "jest --coverage",
"clean": "rm -rf dist",
"rebuild": "npm run clean && npm run build"
},
"dependencies": {
"@modelcontextprotocol/sdk": "^0.5.0",
"zod": "^3.22.4",
"dotenv": "^16.3.1"
},
"devDependencies": {
"@types/node": "^20.10.0",
"@types/jest": "^29.5.0",
"jest": "^29.5.0",
"ts-jest": "^29.1.0",
"tsx": "^4.7.0",
"typescript": "^5.3.0"
},
"engines": {
"node": ">=18.0.0"
}
}

11
railway.json Normal file
View File

@ -0,0 +1,11 @@
{
"$schema": "https://railway.app/railway.schema.json",
"build": {
"builder": "NIXPACKS"
},
"deploy": {
"startCommand": "npm start",
"restartPolicyType": "ON_FAILURE",
"restartPolicyMaxRetries": 10
}
}

392
src/index.ts Normal file
View File

@ -0,0 +1,392 @@
#!/usr/bin/env node
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import {
CallToolRequestSchema,
ListToolsRequestSchema,
} from "@modelcontextprotocol/sdk/types.js";
// ============================================
// CONFIGURATION
// ============================================
const MCP_NAME = "servicetitan";
const MCP_VERSION = "1.0.0";
// ServiceTitan API base URL
const API_BASE_URL = "https://api.servicetitan.io";
const AUTH_URL = "https://auth.servicetitan.io/connect/token";
// ============================================
// API CLIENT
// ============================================
class ServiceTitanClient {
private clientId: string;
private clientSecret: string;
private tenantId: string;
private baseUrl: string;
private accessToken: string | null = null;
private tokenExpiry: number = 0;
constructor(clientId: string, clientSecret: string, tenantId: string) {
this.clientId = clientId;
this.clientSecret = clientSecret;
this.tenantId = tenantId;
this.baseUrl = API_BASE_URL;
}
async getAccessToken(): Promise<string> {
// Return cached token if still valid (with 5 min buffer)
if (this.accessToken && Date.now() < this.tokenExpiry - 300000) {
return this.accessToken;
}
// Request new token using client credentials
const response = await fetch(AUTH_URL, {
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
body: new URLSearchParams({
grant_type: "client_credentials",
client_id: this.clientId,
client_secret: this.clientSecret,
}),
});
if (!response.ok) {
const errorText = await response.text();
throw new Error(`ServiceTitan auth error: ${response.status} - ${errorText}`);
}
const data = await response.json();
this.accessToken = data.access_token;
this.tokenExpiry = Date.now() + (data.expires_in * 1000);
return this.accessToken!;
}
async request(endpoint: string, options: RequestInit = {}) {
const token = await this.getAccessToken();
const url = `${this.baseUrl}${endpoint}`;
const response = await fetch(url, {
...options,
headers: {
"Authorization": `Bearer ${token}`,
"Content-Type": "application/json",
"ST-App-Key": this.clientId,
...options.headers,
},
});
if (!response.ok) {
const errorText = await response.text();
throw new Error(`ServiceTitan API error: ${response.status} ${response.statusText} - ${errorText}`);
}
return response.json();
}
async get(endpoint: string) {
return this.request(endpoint, { method: "GET" });
}
async post(endpoint: string, data: any) {
return this.request(endpoint, {
method: "POST",
body: JSON.stringify(data),
});
}
getTenantId() {
return this.tenantId;
}
}
// ============================================
// TOOL DEFINITIONS
// ============================================
const tools = [
{
name: "list_jobs",
description: "List jobs/work orders. Jobs represent scheduled service work including location, customer, and technician assignments.",
inputSchema: {
type: "object" as const,
properties: {
page: { type: "number", description: "Page number (default 1)" },
pageSize: { type: "number", description: "Results per page (default 50, max 100)" },
status: { type: "string", description: "Filter by status: Scheduled, InProgress, Completed, Canceled" },
customerId: { type: "number", description: "Filter by customer ID" },
technicianId: { type: "number", description: "Filter by technician ID" },
createdOnOrAfter: { type: "string", description: "Filter jobs created on or after (ISO 8601)" },
completedOnOrAfter: { type: "string", description: "Filter jobs completed on or after (ISO 8601)" },
},
},
},
{
name: "get_job",
description: "Get detailed information about a specific job including line items, equipment, and history.",
inputSchema: {
type: "object" as const,
properties: {
job_id: { type: "number", description: "Job ID" },
},
required: ["job_id"],
},
},
{
name: "create_job",
description: "Create a new job/work order. Requires customer, location, and job type.",
inputSchema: {
type: "object" as const,
properties: {
customerId: { type: "number", description: "Customer ID" },
locationId: { type: "number", description: "Service location ID" },
jobTypeId: { type: "number", description: "Job type ID" },
priority: { type: "string", description: "Priority: Low, Normal, High, Urgent" },
businessUnitId: { type: "number", description: "Business unit ID" },
campaignId: { type: "number", description: "Marketing campaign ID" },
summary: { type: "string", description: "Job summary/description" },
scheduledStart: { type: "string", description: "Scheduled start time (ISO 8601)" },
scheduledEnd: { type: "string", description: "Scheduled end time (ISO 8601)" },
},
required: ["customerId", "locationId", "jobTypeId"],
},
},
{
name: "list_customers",
description: "List customers in the CRM. Includes contact info, locations, and account details.",
inputSchema: {
type: "object" as const,
properties: {
page: { type: "number", description: "Page number (default 1)" },
pageSize: { type: "number", description: "Results per page (default 50, max 100)" },
name: { type: "string", description: "Filter by customer name (partial match)" },
email: { type: "string", description: "Filter by email address" },
phone: { type: "string", description: "Filter by phone number" },
createdOnOrAfter: { type: "string", description: "Filter customers created on or after (ISO 8601)" },
active: { type: "boolean", description: "Filter by active status" },
},
},
},
{
name: "get_customer",
description: "Get detailed customer information including all locations, contacts, and service history.",
inputSchema: {
type: "object" as const,
properties: {
customer_id: { type: "number", description: "Customer ID" },
},
required: ["customer_id"],
},
},
{
name: "list_invoices",
description: "List invoices. Includes amounts, status, line items, and payment information.",
inputSchema: {
type: "object" as const,
properties: {
page: { type: "number", description: "Page number (default 1)" },
pageSize: { type: "number", description: "Results per page (default 50, max 100)" },
status: { type: "string", description: "Filter by status: Pending, Posted, Exported" },
customerId: { type: "number", description: "Filter by customer ID" },
jobId: { type: "number", description: "Filter by job ID" },
createdOnOrAfter: { type: "string", description: "Filter invoices created on or after (ISO 8601)" },
total_gte: { type: "number", description: "Filter by minimum total amount" },
},
},
},
{
name: "list_technicians",
description: "List technicians/field workers. Includes contact info, skills, and availability.",
inputSchema: {
type: "object" as const,
properties: {
page: { type: "number", description: "Page number (default 1)" },
pageSize: { type: "number", description: "Results per page (default 50, max 100)" },
active: { type: "boolean", description: "Filter by active status" },
businessUnitId: { type: "number", description: "Filter by business unit" },
},
},
},
{
name: "list_appointments",
description: "List scheduled appointments. Shows booking windows, assigned technicians, and status.",
inputSchema: {
type: "object" as const,
properties: {
page: { type: "number", description: "Page number (default 1)" },
pageSize: { type: "number", description: "Results per page (default 50, max 100)" },
startsOnOrAfter: { type: "string", description: "Filter appointments starting on or after (ISO 8601)" },
startsOnOrBefore: { type: "string", description: "Filter appointments starting on or before (ISO 8601)" },
technicianId: { type: "number", description: "Filter by assigned technician" },
jobId: { type: "number", description: "Filter by job ID" },
},
},
},
];
// ============================================
// TOOL HANDLERS
// ============================================
async function handleTool(client: ServiceTitanClient, name: string, args: any) {
const tenantId = client.getTenantId();
switch (name) {
case "list_jobs": {
const { page = 1, pageSize = 50, status, customerId, technicianId, createdOnOrAfter, completedOnOrAfter } = args;
const params = new URLSearchParams();
params.append("page", String(page));
params.append("pageSize", String(Math.min(pageSize, 100)));
if (status) params.append("status", status);
if (customerId) params.append("customerId", String(customerId));
if (technicianId) params.append("technicianId", String(technicianId));
if (createdOnOrAfter) params.append("createdOnOrAfter", createdOnOrAfter);
if (completedOnOrAfter) params.append("completedOnOrAfter", completedOnOrAfter);
return await client.get(`/jpm/v2/tenant/${tenantId}/jobs?${params}`);
}
case "get_job": {
const { job_id } = args;
return await client.get(`/jpm/v2/tenant/${tenantId}/jobs/${job_id}`);
}
case "create_job": {
const { customerId, locationId, jobTypeId, priority = "Normal", businessUnitId, campaignId, summary, scheduledStart, scheduledEnd } = args;
const jobData: any = {
customerId,
locationId,
jobTypeId,
priority,
};
if (businessUnitId) jobData.businessUnitId = businessUnitId;
if (campaignId) jobData.campaignId = campaignId;
if (summary) jobData.summary = summary;
if (scheduledStart) jobData.start = scheduledStart;
if (scheduledEnd) jobData.end = scheduledEnd;
return await client.post(`/jpm/v2/tenant/${tenantId}/jobs`, jobData);
}
case "list_customers": {
const { page = 1, pageSize = 50, name, email, phone, createdOnOrAfter, active } = args;
const params = new URLSearchParams();
params.append("page", String(page));
params.append("pageSize", String(Math.min(pageSize, 100)));
if (name) params.append("name", name);
if (email) params.append("email", email);
if (phone) params.append("phone", phone);
if (createdOnOrAfter) params.append("createdOnOrAfter", createdOnOrAfter);
if (active !== undefined) params.append("active", String(active));
return await client.get(`/crm/v2/tenant/${tenantId}/customers?${params}`);
}
case "get_customer": {
const { customer_id } = args;
return await client.get(`/crm/v2/tenant/${tenantId}/customers/${customer_id}`);
}
case "list_invoices": {
const { page = 1, pageSize = 50, status, customerId, jobId, createdOnOrAfter, total_gte } = args;
const params = new URLSearchParams();
params.append("page", String(page));
params.append("pageSize", String(Math.min(pageSize, 100)));
if (status) params.append("status", status);
if (customerId) params.append("customerId", String(customerId));
if (jobId) params.append("jobId", String(jobId));
if (createdOnOrAfter) params.append("createdOnOrAfter", createdOnOrAfter);
if (total_gte) params.append("total", `>=${total_gte}`);
return await client.get(`/accounting/v2/tenant/${tenantId}/invoices?${params}`);
}
case "list_technicians": {
const { page = 1, pageSize = 50, active, businessUnitId } = args;
const params = new URLSearchParams();
params.append("page", String(page));
params.append("pageSize", String(Math.min(pageSize, 100)));
if (active !== undefined) params.append("active", String(active));
if (businessUnitId) params.append("businessUnitId", String(businessUnitId));
return await client.get(`/dispatch/v2/tenant/${tenantId}/technicians?${params}`);
}
case "list_appointments": {
const { page = 1, pageSize = 50, startsOnOrAfter, startsOnOrBefore, technicianId, jobId } = args;
const params = new URLSearchParams();
params.append("page", String(page));
params.append("pageSize", String(Math.min(pageSize, 100)));
if (startsOnOrAfter) params.append("startsOnOrAfter", startsOnOrAfter);
if (startsOnOrBefore) params.append("startsOnOrBefore", startsOnOrBefore);
if (technicianId) params.append("technicianId", String(technicianId));
if (jobId) params.append("jobId", String(jobId));
return await client.get(`/dispatch/v2/tenant/${tenantId}/appointments?${params}`);
}
default:
throw new Error(`Unknown tool: ${name}`);
}
}
// ============================================
// SERVER SETUP
// ============================================
async function main() {
const clientId = process.env.SERVICETITAN_CLIENT_ID;
const clientSecret = process.env.SERVICETITAN_CLIENT_SECRET;
const tenantId = process.env.SERVICETITAN_TENANT_ID;
if (!clientId) {
console.error("Error: SERVICETITAN_CLIENT_ID environment variable required");
process.exit(1);
}
if (!clientSecret) {
console.error("Error: SERVICETITAN_CLIENT_SECRET environment variable required");
process.exit(1);
}
if (!tenantId) {
console.error("Error: SERVICETITAN_TENANT_ID environment variable required");
process.exit(1);
}
const client = new ServiceTitanClient(clientId, clientSecret, tenantId);
const server = new Server(
{ name: `${MCP_NAME}-mcp`, version: MCP_VERSION },
{ capabilities: { tools: {} } }
);
server.setRequestHandler(ListToolsRequestSchema, async () => ({
tools,
}));
server.setRequestHandler(CallToolRequestSchema, async (request) => {
const { name, arguments: args } = request.params;
try {
const result = await handleTool(client, name, args || {});
return {
content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
};
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
return {
content: [{ type: "text", text: `Error: ${message}` }],
isError: true,
};
}
});
const transport = new StdioServerTransport();
await server.connect(transport);
console.error(`${MCP_NAME} MCP server running on stdio`);
}
main().catch(console.error);

15
tsconfig.json Normal file
View File

@ -0,0 +1,15 @@
{
"compilerOptions": {
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"outDir": "./dist",
"rootDir": "./src",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"declaration": true
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist"]
}