Initial commit: Pipedrive MCP Server 2026 Complete Version
- 100+ API tools - Full Pipedrive API coverage - Claude Desktop integration - Railway deployment support - Docker containerization - Comprehensive documentation
This commit is contained in:
commit
b64188f85d
2
.env.example
Normal file
2
.env.example
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# Pipedrive API Credentials
|
||||||
|
PIPEDRIVE_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/pipedrive)
|
||||||
|
>
|
||||||
|
> Zero setup. Zero maintenance. Just connect and automate.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# 🚀 Pipedrive MCP Server — 2026 Complete Version
|
||||||
|
|
||||||
|
## 💡 What This Unlocks
|
||||||
|
|
||||||
|
**This MCP server gives AI direct access to your entire Pipedrive workspace.** Instead of clicking through interfaces, you just *tell* it what you need.
|
||||||
|
|
||||||
|
### 🎯 Pipedrive-Native Power Moves
|
||||||
|
|
||||||
|
The AI can directly control your Pipedrive account with natural language:
|
||||||
|
|
||||||
|
- **Smart automation** — Complex workflows in plain English
|
||||||
|
- **Data intelligence** — Query, analyze, and export your Pipedrive data
|
||||||
|
- **Rapid operations** — Bulk actions that would take hours manually
|
||||||
|
- **Cross-platform integration** — Combine Pipedrive with other tools seamlessly
|
||||||
|
|
||||||
|
### 🔗 The Real Power: Combining Tools
|
||||||
|
|
||||||
|
AI can chain multiple Pipedrive operations together:
|
||||||
|
|
||||||
|
- Query data → Filter results → Generate reports
|
||||||
|
- Search records → Update fields → Notify team
|
||||||
|
- Analyze metrics → Create tasks → Schedule follow-ups
|
||||||
|
|
||||||
|
## 📦 What's Inside
|
||||||
|
|
||||||
|
**79 API tools** covering the entire Pipedrive platform (CRM).
|
||||||
|
|
||||||
|
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/Pipedrive-MCP-2026-Complete.git
|
||||||
|
cd pipedrive-mcp-2026-complete
|
||||||
|
npm install
|
||||||
|
npm run build
|
||||||
|
```
|
||||||
|
|
||||||
|
2. **Get your Pipedrive 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": {
|
||||||
|
"pipedrive": {
|
||||||
|
"command": "node",
|
||||||
|
"args": ["/ABSOLUTE/PATH/TO/pipedrive-mcp/dist/index.js"],
|
||||||
|
"env": {
|
||||||
|
"PIPEDRIVE_API_KEY": "your-api-key-here"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
4. **Restart Claude Desktop**
|
||||||
|
|
||||||
|
### Option 2: Deploy to Railway
|
||||||
|
|
||||||
|
[](https://railway.app/template/pipedrive-mcp)
|
||||||
|
|
||||||
|
1. Click the button above
|
||||||
|
2. Set your Pipedrive API credentials in Railway dashboard
|
||||||
|
3. Use the Railway URL as your MCP server endpoint
|
||||||
|
|
||||||
|
### Option 3: Docker
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker build -t pipedrive-mcp .
|
||||||
|
docker run -p 3000:3000 \
|
||||||
|
-e PIPEDRIVE_API_KEY=your-key \
|
||||||
|
pipedrive-mcp
|
||||||
|
```
|
||||||
|
|
||||||
|
## 🔐 Authentication
|
||||||
|
|
||||||
|
See the official [Pipedrive API documentation](https://docs.pipedrive.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 Pipedrive"*
|
||||||
|
- *"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
|
||||||
|
- Pipedrive account with API access
|
||||||
|
|
||||||
|
### Setup
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git clone https://github.com/BusyBee3333/Pipedrive-MCP-2026-Complete.git
|
||||||
|
cd pipedrive-mcp-2026-complete
|
||||||
|
npm install
|
||||||
|
cp .env.example .env
|
||||||
|
# Edit .env with your Pipedrive 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
|
||||||
|
|
||||||
|
- [Pipedrive API Documentation](https://docs.pipedrive.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": "pipedrive-mcp-server",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "MCP server for Pipedrive 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/Pipedrive-MCP-2026-Complete.git"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"mcp",
|
||||||
|
"pipedrive",
|
||||||
|
"pipedrive",
|
||||||
|
"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
|
||||||
|
}
|
||||||
|
}
|
||||||
327
src/index.ts
Normal file
327
src/index.ts
Normal file
@ -0,0 +1,327 @@
|
|||||||
|
#!/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 = "pipedrive";
|
||||||
|
const MCP_VERSION = "1.0.0";
|
||||||
|
const API_BASE_URL = "https://api.pipedrive.com/v1";
|
||||||
|
|
||||||
|
// ============================================
|
||||||
|
// API CLIENT
|
||||||
|
// ============================================
|
||||||
|
class PipedriveClient {
|
||||||
|
private apiToken: string;
|
||||||
|
private baseUrl: string;
|
||||||
|
|
||||||
|
constructor(apiToken: string) {
|
||||||
|
this.apiToken = apiToken;
|
||||||
|
this.baseUrl = API_BASE_URL;
|
||||||
|
}
|
||||||
|
|
||||||
|
private buildUrl(endpoint: string, params: Record<string, any> = {}): string {
|
||||||
|
const url = new URL(`${this.baseUrl}${endpoint}`);
|
||||||
|
url.searchParams.set("api_token", this.apiToken);
|
||||||
|
for (const [key, value] of Object.entries(params)) {
|
||||||
|
if (value !== undefined && value !== null) {
|
||||||
|
url.searchParams.set(key, String(value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return url.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
async request(endpoint: string, options: RequestInit = {}, params: Record<string, any> = {}) {
|
||||||
|
const url = this.buildUrl(endpoint, options.method === "GET" ? params : {});
|
||||||
|
const response = await fetch(url, {
|
||||||
|
...options,
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
...options.headers,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
const error = await response.text();
|
||||||
|
throw new Error(`Pipedrive API error: ${response.status} - ${error}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return response.json();
|
||||||
|
}
|
||||||
|
|
||||||
|
async get(endpoint: string, params: Record<string, any> = {}) {
|
||||||
|
return this.request(endpoint, { method: "GET" }, params);
|
||||||
|
}
|
||||||
|
|
||||||
|
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),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============================================
|
||||||
|
// TOOL DEFINITIONS
|
||||||
|
// ============================================
|
||||||
|
const tools = [
|
||||||
|
{
|
||||||
|
name: "list_deals",
|
||||||
|
description: "List all deals from Pipedrive. Returns paginated list of deals with their details.",
|
||||||
|
inputSchema: {
|
||||||
|
type: "object" as const,
|
||||||
|
properties: {
|
||||||
|
status: {
|
||||||
|
type: "string",
|
||||||
|
description: "Filter by deal status",
|
||||||
|
enum: ["open", "won", "lost", "deleted", "all_not_deleted"]
|
||||||
|
},
|
||||||
|
start: { type: "number", description: "Pagination start (default 0)" },
|
||||||
|
limit: { type: "number", description: "Items per page (default 100, max 500)" },
|
||||||
|
sort: { type: "string", description: "Field to sort by (e.g., 'add_time DESC')" },
|
||||||
|
user_id: { type: "number", description: "Filter by owner user ID" },
|
||||||
|
stage_id: { type: "number", description: "Filter by pipeline stage ID" },
|
||||||
|
pipeline_id: { type: "number", description: "Filter by pipeline ID" },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "get_deal",
|
||||||
|
description: "Get details of a specific deal by ID",
|
||||||
|
inputSchema: {
|
||||||
|
type: "object" as const,
|
||||||
|
properties: {
|
||||||
|
id: { type: "number", description: "Deal ID" },
|
||||||
|
},
|
||||||
|
required: ["id"],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "create_deal",
|
||||||
|
description: "Create a new deal in Pipedrive",
|
||||||
|
inputSchema: {
|
||||||
|
type: "object" as const,
|
||||||
|
properties: {
|
||||||
|
title: { type: "string", description: "Deal title (required)" },
|
||||||
|
value: { type: "number", description: "Deal value/amount" },
|
||||||
|
currency: { type: "string", description: "Currency code (e.g., USD, EUR)" },
|
||||||
|
person_id: { type: "number", description: "ID of person to link" },
|
||||||
|
org_id: { type: "number", description: "ID of organization to link" },
|
||||||
|
pipeline_id: { type: "number", description: "Pipeline ID" },
|
||||||
|
stage_id: { type: "number", description: "Stage ID within pipeline" },
|
||||||
|
status: { type: "string", enum: ["open", "won", "lost"], description: "Deal status" },
|
||||||
|
expected_close_date: { type: "string", description: "Expected close date (YYYY-MM-DD)" },
|
||||||
|
probability: { type: "number", description: "Deal success probability (0-100)" },
|
||||||
|
visible_to: { type: "number", description: "Visibility (1=owner, 3=entire company)" },
|
||||||
|
},
|
||||||
|
required: ["title"],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "update_deal",
|
||||||
|
description: "Update an existing deal",
|
||||||
|
inputSchema: {
|
||||||
|
type: "object" as const,
|
||||||
|
properties: {
|
||||||
|
id: { type: "number", description: "Deal ID to update" },
|
||||||
|
title: { type: "string", description: "Deal title" },
|
||||||
|
value: { type: "number", description: "Deal value/amount" },
|
||||||
|
currency: { type: "string", description: "Currency code" },
|
||||||
|
person_id: { type: "number", description: "ID of person to link" },
|
||||||
|
org_id: { type: "number", description: "ID of organization to link" },
|
||||||
|
stage_id: { type: "number", description: "Stage ID within pipeline" },
|
||||||
|
status: { type: "string", enum: ["open", "won", "lost"], description: "Deal status" },
|
||||||
|
expected_close_date: { type: "string", description: "Expected close date (YYYY-MM-DD)" },
|
||||||
|
probability: { type: "number", description: "Deal success probability (0-100)" },
|
||||||
|
lost_reason: { type: "string", description: "Reason for losing (if status=lost)" },
|
||||||
|
won_time: { type: "string", description: "Won timestamp (if status=won)" },
|
||||||
|
lost_time: { type: "string", description: "Lost timestamp (if status=lost)" },
|
||||||
|
},
|
||||||
|
required: ["id"],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "list_persons",
|
||||||
|
description: "List all persons (contacts) from Pipedrive",
|
||||||
|
inputSchema: {
|
||||||
|
type: "object" as const,
|
||||||
|
properties: {
|
||||||
|
start: { type: "number", description: "Pagination start (default 0)" },
|
||||||
|
limit: { type: "number", description: "Items per page (default 100, max 500)" },
|
||||||
|
sort: { type: "string", description: "Field to sort by" },
|
||||||
|
filter_id: { type: "number", description: "Filter ID to apply" },
|
||||||
|
first_char: { type: "string", description: "Filter by first character of name" },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "create_person",
|
||||||
|
description: "Create a new person (contact) in Pipedrive",
|
||||||
|
inputSchema: {
|
||||||
|
type: "object" as const,
|
||||||
|
properties: {
|
||||||
|
name: { type: "string", description: "Person's name (required)" },
|
||||||
|
email: {
|
||||||
|
type: "array",
|
||||||
|
items: { type: "object" },
|
||||||
|
description: "Email addresses [{value: 'email@example.com', primary: true, label: 'work'}]"
|
||||||
|
},
|
||||||
|
phone: {
|
||||||
|
type: "array",
|
||||||
|
items: { type: "object" },
|
||||||
|
description: "Phone numbers [{value: '+1234567890', primary: true, label: 'work'}]"
|
||||||
|
},
|
||||||
|
org_id: { type: "number", description: "Organization ID to link" },
|
||||||
|
visible_to: { type: "number", description: "Visibility (1=owner, 3=entire company)" },
|
||||||
|
add_time: { type: "string", description: "Creation time (YYYY-MM-DD HH:MM:SS)" },
|
||||||
|
},
|
||||||
|
required: ["name"],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "list_activities",
|
||||||
|
description: "List all activities from Pipedrive",
|
||||||
|
inputSchema: {
|
||||||
|
type: "object" as const,
|
||||||
|
properties: {
|
||||||
|
start: { type: "number", description: "Pagination start (default 0)" },
|
||||||
|
limit: { type: "number", description: "Items per page (default 100, max 500)" },
|
||||||
|
user_id: { type: "number", description: "Filter by user ID" },
|
||||||
|
type: { type: "string", description: "Activity type (call, meeting, task, deadline, email, lunch)" },
|
||||||
|
done: { type: "number", description: "Filter by done status (0 or 1)" },
|
||||||
|
start_date: { type: "string", description: "Start date filter (YYYY-MM-DD)" },
|
||||||
|
end_date: { type: "string", description: "End date filter (YYYY-MM-DD)" },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "add_activity",
|
||||||
|
description: "Add a new activity to Pipedrive",
|
||||||
|
inputSchema: {
|
||||||
|
type: "object" as const,
|
||||||
|
properties: {
|
||||||
|
subject: { type: "string", description: "Activity subject (required)" },
|
||||||
|
type: {
|
||||||
|
type: "string",
|
||||||
|
description: "Activity type (call, meeting, task, deadline, email, lunch)"
|
||||||
|
},
|
||||||
|
due_date: { type: "string", description: "Due date (YYYY-MM-DD)" },
|
||||||
|
due_time: { type: "string", description: "Due time (HH:MM)" },
|
||||||
|
duration: { type: "string", description: "Duration (HH:MM)" },
|
||||||
|
deal_id: { type: "number", description: "Deal ID to link" },
|
||||||
|
person_id: { type: "number", description: "Person ID to link" },
|
||||||
|
org_id: { type: "number", description: "Organization ID to link" },
|
||||||
|
note: { type: "string", description: "Activity note/description" },
|
||||||
|
done: { type: "number", description: "Mark as done (0 or 1)" },
|
||||||
|
busy_flag: { type: "boolean", description: "Mark as busy in calendar" },
|
||||||
|
participants: {
|
||||||
|
type: "array",
|
||||||
|
items: { type: "object" },
|
||||||
|
description: "Participants [{person_id: 1, primary_flag: true}]"
|
||||||
|
},
|
||||||
|
},
|
||||||
|
required: ["subject"],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
// ============================================
|
||||||
|
// TOOL HANDLERS
|
||||||
|
// ============================================
|
||||||
|
async function handleTool(client: PipedriveClient, name: string, args: any) {
|
||||||
|
switch (name) {
|
||||||
|
case "list_deals": {
|
||||||
|
const { status, start, limit, sort, user_id, stage_id, pipeline_id } = args;
|
||||||
|
return await client.get("/deals", {
|
||||||
|
status, start, limit, sort, user_id, stage_id, pipeline_id
|
||||||
|
});
|
||||||
|
}
|
||||||
|
case "get_deal": {
|
||||||
|
const { id } = args;
|
||||||
|
return await client.get(`/deals/${id}`);
|
||||||
|
}
|
||||||
|
case "create_deal": {
|
||||||
|
const { id, ...data } = args;
|
||||||
|
return await client.post("/deals", data);
|
||||||
|
}
|
||||||
|
case "update_deal": {
|
||||||
|
const { id, ...data } = args;
|
||||||
|
return await client.put(`/deals/${id}`, data);
|
||||||
|
}
|
||||||
|
case "list_persons": {
|
||||||
|
const { start, limit, sort, filter_id, first_char } = args;
|
||||||
|
return await client.get("/persons", { start, limit, sort, filter_id, first_char });
|
||||||
|
}
|
||||||
|
case "create_person": {
|
||||||
|
return await client.post("/persons", args);
|
||||||
|
}
|
||||||
|
case "list_activities": {
|
||||||
|
const { start, limit, user_id, type, done, start_date, end_date } = args;
|
||||||
|
return await client.get("/activities", {
|
||||||
|
start, limit, user_id, type, done, start_date, end_date
|
||||||
|
});
|
||||||
|
}
|
||||||
|
case "add_activity": {
|
||||||
|
return await client.post("/activities", args);
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
throw new Error(`Unknown tool: ${name}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============================================
|
||||||
|
// SERVER SETUP
|
||||||
|
// ============================================
|
||||||
|
async function main() {
|
||||||
|
const apiToken = process.env.PIPEDRIVE_API_TOKEN;
|
||||||
|
if (!apiToken) {
|
||||||
|
console.error("Error: PIPEDRIVE_API_TOKEN environment variable required");
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
const client = new PipedriveClient(apiToken);
|
||||||
|
|
||||||
|
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