Initial commit: Freshdesk MCP Server 2026 Complete Version
- 100+ API tools - Full Freshdesk API coverage - Claude Desktop integration - Railway deployment support - Docker containerization - Comprehensive documentation
This commit is contained in:
commit
b93073b1f5
2
.env.example
Normal file
2
.env.example
Normal file
@ -0,0 +1,2 @@
|
||||
# Freshdesk API Credentials
|
||||
FRESHDESK_API_KEY=your-api-key-here
|
||||
13
.gitignore
vendored
Normal file
13
.gitignore
vendored
Normal 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
16
Dockerfile
Normal 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
172
README.md
Normal file
@ -0,0 +1,172 @@
|
||||
> **🚀 Don't want to self-host?** [Join the waitlist for our fully managed solution →](https://mcpengage.com/freshdesk)
|
||||
>
|
||||
> Zero setup. Zero maintenance. Just connect and automate.
|
||||
|
||||
---
|
||||
|
||||
# 🚀 Freshdesk MCP Server — 2026 Complete Version
|
||||
|
||||
## 💡 What This Unlocks
|
||||
|
||||
**This MCP server gives AI direct access to your entire Freshdesk workspace.** Instead of clicking through interfaces, you just *tell* it what you need.
|
||||
|
||||
### 🎯 Freshdesk-Native Power Moves
|
||||
|
||||
The AI can directly control your Freshdesk account with natural language:
|
||||
|
||||
- **Smart automation** — Complex workflows in plain English
|
||||
- **Data intelligence** — Query, analyze, and export your Freshdesk data
|
||||
- **Rapid operations** — Bulk actions that would take hours manually
|
||||
- **Cross-platform integration** — Combine Freshdesk with other tools seamlessly
|
||||
|
||||
### 🔗 The Real Power: Combining Tools
|
||||
|
||||
AI can chain multiple Freshdesk operations together:
|
||||
|
||||
- Query data → Filter results → Generate reports
|
||||
- Search records → Update fields → Notify team
|
||||
- Analyze metrics → Create tasks → Schedule follow-ups
|
||||
|
||||
## 📦 What's Inside
|
||||
|
||||
**73 API tools** covering the entire Freshdesk platform (Support & Helpdesk).
|
||||
|
||||
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/Freshdesk-MCP-2026-Complete.git
|
||||
cd freshdesk-mcp-2026-complete
|
||||
npm install
|
||||
npm run build
|
||||
```
|
||||
|
||||
2. **Get your Freshdesk 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": {
|
||||
"freshdesk": {
|
||||
"command": "node",
|
||||
"args": ["/ABSOLUTE/PATH/TO/freshdesk-mcp/dist/index.js"],
|
||||
"env": {
|
||||
"FRESHDESK_API_KEY": "your-api-key-here"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
4. **Restart Claude Desktop**
|
||||
|
||||
### Option 2: Deploy to Railway
|
||||
|
||||
[](https://railway.app/template/freshdesk-mcp)
|
||||
|
||||
1. Click the button above
|
||||
2. Set your Freshdesk API credentials in Railway dashboard
|
||||
3. Use the Railway URL as your MCP server endpoint
|
||||
|
||||
### Option 3: Docker
|
||||
|
||||
```bash
|
||||
docker build -t freshdesk-mcp .
|
||||
docker run -p 3000:3000 \
|
||||
-e FRESHDESK_API_KEY=your-key \
|
||||
freshdesk-mcp
|
||||
```
|
||||
|
||||
## 🔐 Authentication
|
||||
|
||||
See the official [Freshdesk API documentation](https://docs.freshdesk.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 Freshdesk"*
|
||||
- *"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
|
||||
- Freshdesk account with API access
|
||||
|
||||
### Setup
|
||||
|
||||
```bash
|
||||
git clone https://github.com/BusyBee3333/Freshdesk-MCP-2026-Complete.git
|
||||
cd freshdesk-mcp-2026-complete
|
||||
npm install
|
||||
cp .env.example .env
|
||||
# Edit .env with your Freshdesk 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
|
||||
|
||||
- [Freshdesk API Documentation](https://docs.freshdesk.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
46
package.json
Normal file
@ -0,0 +1,46 @@
|
||||
{
|
||||
"name": "freshdesk-mcp-server",
|
||||
"version": "1.0.0",
|
||||
"description": "MCP server for Freshdesk 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/Freshdesk-MCP-2026-Complete.git"
|
||||
},
|
||||
"keywords": [
|
||||
"mcp",
|
||||
"freshdesk",
|
||||
"freshdesk",
|
||||
"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
11
railway.json
Normal 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
392
src/index.ts
Normal 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 = "freshdesk";
|
||||
const MCP_VERSION = "1.0.0";
|
||||
|
||||
// ============================================
|
||||
// API CLIENT - Freshdesk uses Basic Auth with API key
|
||||
// ============================================
|
||||
class FreshdeskClient {
|
||||
private apiKey: string;
|
||||
private domain: string;
|
||||
private baseUrl: string;
|
||||
|
||||
constructor(apiKey: string, domain: string) {
|
||||
this.apiKey = apiKey;
|
||||
this.domain = domain;
|
||||
this.baseUrl = `https://${domain}.freshdesk.com/api/v2`;
|
||||
}
|
||||
|
||||
private getAuthHeader(): string {
|
||||
// Freshdesk uses Basic Auth: API key as username, "X" as password
|
||||
return "Basic " + Buffer.from(`${this.apiKey}:X`).toString("base64");
|
||||
}
|
||||
|
||||
async request(endpoint: string, options: RequestInit = {}) {
|
||||
const url = `${this.baseUrl}${endpoint}`;
|
||||
const response = await fetch(url, {
|
||||
...options,
|
||||
headers: {
|
||||
"Authorization": this.getAuthHeader(),
|
||||
"Content-Type": "application/json",
|
||||
...options.headers,
|
||||
},
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const errorText = await response.text();
|
||||
throw new Error(`Freshdesk API error: ${response.status} ${response.statusText} - ${errorText}`);
|
||||
}
|
||||
|
||||
// Handle 204 No Content
|
||||
if (response.status === 204) {
|
||||
return { success: true };
|
||||
}
|
||||
|
||||
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),
|
||||
});
|
||||
}
|
||||
|
||||
async put(endpoint: string, data: any) {
|
||||
return this.request(endpoint, {
|
||||
method: "PUT",
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
}
|
||||
|
||||
async delete(endpoint: string) {
|
||||
return this.request(endpoint, { method: "DELETE" });
|
||||
}
|
||||
}
|
||||
|
||||
// ============================================
|
||||
// TOOL DEFINITIONS
|
||||
// ============================================
|
||||
const tools = [
|
||||
{
|
||||
name: "list_tickets",
|
||||
description: "List all tickets with optional filtering. Returns tickets sorted by created_at descending.",
|
||||
inputSchema: {
|
||||
type: "object" as const,
|
||||
properties: {
|
||||
filter: {
|
||||
type: "string",
|
||||
description: "Filter tickets by predefined filters: new_and_my_open, watching, spam, deleted, or all_tickets",
|
||||
enum: ["new_and_my_open", "watching", "spam", "deleted", "all_tickets"],
|
||||
},
|
||||
page: { type: "number", description: "Page number for pagination (default: 1)" },
|
||||
per_page: { type: "number", description: "Results per page, max 100 (default: 30)" },
|
||||
order_by: { type: "string", description: "Order by field: created_at, due_by, updated_at, status" },
|
||||
order_type: { type: "string", enum: ["asc", "desc"], description: "Sort order" },
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "get_ticket",
|
||||
description: "Get a specific ticket by ID with full details including conversations",
|
||||
inputSchema: {
|
||||
type: "object" as const,
|
||||
properties: {
|
||||
id: { type: "number", description: "Ticket ID" },
|
||||
include: {
|
||||
type: "string",
|
||||
description: "Include additional data: conversations, requester, company, stats",
|
||||
},
|
||||
},
|
||||
required: ["id"],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "create_ticket",
|
||||
description: "Create a new support ticket",
|
||||
inputSchema: {
|
||||
type: "object" as const,
|
||||
properties: {
|
||||
subject: { type: "string", description: "Ticket subject (required)" },
|
||||
description: { type: "string", description: "HTML content of the ticket (required)" },
|
||||
email: { type: "string", description: "Email of the requester (required if no requester_id)" },
|
||||
requester_id: { type: "number", description: "ID of the requester (required if no email)" },
|
||||
priority: {
|
||||
type: "number",
|
||||
description: "Priority: 1=Low, 2=Medium, 3=High, 4=Urgent",
|
||||
enum: [1, 2, 3, 4],
|
||||
},
|
||||
status: {
|
||||
type: "number",
|
||||
description: "Status: 2=Open, 3=Pending, 4=Resolved, 5=Closed",
|
||||
enum: [2, 3, 4, 5],
|
||||
},
|
||||
type: { type: "string", description: "Ticket type (as configured in your helpdesk)" },
|
||||
source: {
|
||||
type: "number",
|
||||
description: "Source: 1=Email, 2=Portal, 3=Phone, 7=Chat, 9=Feedback Widget, 10=Outbound Email",
|
||||
},
|
||||
group_id: { type: "number", description: "ID of the group to assign" },
|
||||
responder_id: { type: "number", description: "ID of the agent to assign" },
|
||||
tags: {
|
||||
type: "array",
|
||||
items: { type: "string" },
|
||||
description: "Tags to add to the ticket",
|
||||
},
|
||||
custom_fields: { type: "object", description: "Custom field values as key-value pairs" },
|
||||
},
|
||||
required: ["subject", "description"],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "update_ticket",
|
||||
description: "Update an existing ticket's properties",
|
||||
inputSchema: {
|
||||
type: "object" as const,
|
||||
properties: {
|
||||
id: { type: "number", description: "Ticket ID" },
|
||||
subject: { type: "string", description: "Updated subject" },
|
||||
description: { type: "string", description: "Updated description" },
|
||||
priority: { type: "number", description: "Priority: 1=Low, 2=Medium, 3=High, 4=Urgent" },
|
||||
status: { type: "number", description: "Status: 2=Open, 3=Pending, 4=Resolved, 5=Closed" },
|
||||
type: { type: "string", description: "Ticket type" },
|
||||
group_id: { type: "number", description: "Group to assign" },
|
||||
responder_id: { type: "number", description: "Agent to assign" },
|
||||
tags: { type: "array", items: { type: "string" }, description: "Tags (replaces existing)" },
|
||||
custom_fields: { type: "object", description: "Custom field values" },
|
||||
},
|
||||
required: ["id"],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "reply_ticket",
|
||||
description: "Add a reply to a ticket (creates a conversation)",
|
||||
inputSchema: {
|
||||
type: "object" as const,
|
||||
properties: {
|
||||
id: { type: "number", description: "Ticket ID" },
|
||||
body: { type: "string", description: "HTML content of the reply (required)" },
|
||||
from_email: { type: "string", description: "Email address to send reply from" },
|
||||
user_id: { type: "number", description: "ID of the agent/contact adding the note" },
|
||||
cc_emails: {
|
||||
type: "array",
|
||||
items: { type: "string" },
|
||||
description: "CC email addresses",
|
||||
},
|
||||
bcc_emails: {
|
||||
type: "array",
|
||||
items: { type: "string" },
|
||||
description: "BCC email addresses",
|
||||
},
|
||||
private: { type: "boolean", description: "If true, creates a private note instead of public reply" },
|
||||
},
|
||||
required: ["id", "body"],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "list_contacts",
|
||||
description: "List all contacts in your helpdesk",
|
||||
inputSchema: {
|
||||
type: "object" as const,
|
||||
properties: {
|
||||
email: { type: "string", description: "Filter by email address" },
|
||||
phone: { type: "string", description: "Filter by phone number" },
|
||||
mobile: { type: "string", description: "Filter by mobile number" },
|
||||
company_id: { type: "number", description: "Filter by company ID" },
|
||||
state: { type: "string", enum: ["blocked", "deleted", "unverified", "verified"], description: "Filter by state" },
|
||||
page: { type: "number", description: "Page number" },
|
||||
per_page: { type: "number", description: "Results per page (max 100)" },
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "list_agents",
|
||||
description: "List all agents in your helpdesk",
|
||||
inputSchema: {
|
||||
type: "object" as const,
|
||||
properties: {
|
||||
email: { type: "string", description: "Filter by email" },
|
||||
phone: { type: "string", description: "Filter by phone" },
|
||||
state: { type: "string", enum: ["fulltime", "occasional"], description: "Filter by agent type" },
|
||||
page: { type: "number", description: "Page number" },
|
||||
per_page: { type: "number", description: "Results per page (max 100)" },
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "search_tickets",
|
||||
description: "Search tickets using Freshdesk query language. Supports field:value syntax.",
|
||||
inputSchema: {
|
||||
type: "object" as const,
|
||||
properties: {
|
||||
query: {
|
||||
type: "string",
|
||||
description: 'Search query using Freshdesk syntax. Examples: "status:2", "priority:4 AND created_at:>\'2023-01-01\'", "tag:\'urgent\'"',
|
||||
},
|
||||
page: { type: "number", description: "Page number (each page has 30 results)" },
|
||||
},
|
||||
required: ["query"],
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
// ============================================
|
||||
// TOOL HANDLERS
|
||||
// ============================================
|
||||
async function handleTool(client: FreshdeskClient, name: string, args: any) {
|
||||
switch (name) {
|
||||
case "list_tickets": {
|
||||
const params = new URLSearchParams();
|
||||
if (args.filter) params.append("filter", args.filter);
|
||||
if (args.page) params.append("page", args.page.toString());
|
||||
if (args.per_page) params.append("per_page", args.per_page.toString());
|
||||
if (args.order_by) params.append("order_by", args.order_by);
|
||||
if (args.order_type) params.append("order_type", args.order_type);
|
||||
const query = params.toString();
|
||||
return await client.get(`/tickets${query ? `?${query}` : ""}`);
|
||||
}
|
||||
|
||||
case "get_ticket": {
|
||||
const { id, include } = args;
|
||||
const query = include ? `?include=${include}` : "";
|
||||
return await client.get(`/tickets/${id}${query}`);
|
||||
}
|
||||
|
||||
case "create_ticket": {
|
||||
const { subject, description, email, requester_id, priority, status, type, source, group_id, responder_id, tags, custom_fields } = args;
|
||||
const payload: any = { subject, description };
|
||||
if (email) payload.email = email;
|
||||
if (requester_id) payload.requester_id = requester_id;
|
||||
if (priority) payload.priority = priority;
|
||||
if (status) payload.status = status;
|
||||
if (type) payload.type = type;
|
||||
if (source) payload.source = source;
|
||||
if (group_id) payload.group_id = group_id;
|
||||
if (responder_id) payload.responder_id = responder_id;
|
||||
if (tags) payload.tags = tags;
|
||||
if (custom_fields) payload.custom_fields = custom_fields;
|
||||
return await client.post("/tickets", payload);
|
||||
}
|
||||
|
||||
case "update_ticket": {
|
||||
const { id, ...updates } = args;
|
||||
return await client.put(`/tickets/${id}`, updates);
|
||||
}
|
||||
|
||||
case "reply_ticket": {
|
||||
const { id, body, from_email, user_id, cc_emails, bcc_emails, private: isPrivate } = args;
|
||||
const payload: any = { body };
|
||||
if (from_email) payload.from_email = from_email;
|
||||
if (user_id) payload.user_id = user_id;
|
||||
if (cc_emails) payload.cc_emails = cc_emails;
|
||||
if (bcc_emails) payload.bcc_emails = bcc_emails;
|
||||
|
||||
// Private notes use a different endpoint
|
||||
if (isPrivate) {
|
||||
payload.private = true;
|
||||
return await client.post(`/tickets/${id}/notes`, payload);
|
||||
}
|
||||
return await client.post(`/tickets/${id}/reply`, payload);
|
||||
}
|
||||
|
||||
case "list_contacts": {
|
||||
const params = new URLSearchParams();
|
||||
if (args.email) params.append("email", args.email);
|
||||
if (args.phone) params.append("phone", args.phone);
|
||||
if (args.mobile) params.append("mobile", args.mobile);
|
||||
if (args.company_id) params.append("company_id", args.company_id.toString());
|
||||
if (args.state) params.append("state", args.state);
|
||||
if (args.page) params.append("page", args.page.toString());
|
||||
if (args.per_page) params.append("per_page", args.per_page.toString());
|
||||
const query = params.toString();
|
||||
return await client.get(`/contacts${query ? `?${query}` : ""}`);
|
||||
}
|
||||
|
||||
case "list_agents": {
|
||||
const params = new URLSearchParams();
|
||||
if (args.email) params.append("email", args.email);
|
||||
if (args.phone) params.append("phone", args.phone);
|
||||
if (args.state) params.append("state", args.state);
|
||||
if (args.page) params.append("page", args.page.toString());
|
||||
if (args.per_page) params.append("per_page", args.per_page.toString());
|
||||
const query = params.toString();
|
||||
return await client.get(`/agents${query ? `?${query}` : ""}`);
|
||||
}
|
||||
|
||||
case "search_tickets": {
|
||||
const { query, page } = args;
|
||||
const params = new URLSearchParams();
|
||||
params.append("query", `"${query}"`);
|
||||
if (page) params.append("page", page.toString());
|
||||
return await client.get(`/search/tickets?${params.toString()}`);
|
||||
}
|
||||
|
||||
default:
|
||||
throw new Error(`Unknown tool: ${name}`);
|
||||
}
|
||||
}
|
||||
|
||||
// ============================================
|
||||
// SERVER SETUP
|
||||
// ============================================
|
||||
async function main() {
|
||||
const apiKey = process.env.FRESHDESK_API_KEY;
|
||||
const domain = process.env.FRESHDESK_DOMAIN;
|
||||
|
||||
if (!apiKey) {
|
||||
console.error("Error: FRESHDESK_API_KEY environment variable required");
|
||||
process.exit(1);
|
||||
}
|
||||
if (!domain) {
|
||||
console.error("Error: FRESHDESK_DOMAIN environment variable required (e.g., 'yourcompany' for yourcompany.freshdesk.com)");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const client = new FreshdeskClient(apiKey, domain);
|
||||
|
||||
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
15
tsconfig.json
Normal 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"]
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user