-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathepiphany-mcp-server.js
More file actions
191 lines (170 loc) · 6.28 KB
/
epiphany-mcp-server.js
File metadata and controls
191 lines (170 loc) · 6.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
// epiphany-mcp-server.js
// MCP server implementation for Epiphany Booking API
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
import {
CallToolRequestSchema,
ListToolsRequestSchema,
} from '@modelcontextprotocol/sdk/types.js';
const API_KEY = process.env.EPIPHANY_API_KEY;
const BASE_URL = 'https://epiphany.so/api/v1';
class EpiphanyMCPServer {
constructor() {
this.server = new Server(
{
name: 'epiphany-booking-server',
version: '1.0.0',
},
{
capabilities: {
tools: {},
},
}
);
this.setupHandlers();
}
async makeRequest(endpoint, method = 'GET', body = null) {
const options = {
method,
headers: {
'X-API-Key': API_KEY,
'Content-Type': 'application/json',
},
};
if (body) {
options.body = JSON.stringify(body);
}
const response = await fetch(`${BASE_URL}${endpoint}`, options);
if (!response.ok) {
throw new Error(`API Error: ${response.status} ${response.statusText}`);
}
return response.json();
}
setupHandlers() {
// List available tools
this.server.setRequestHandler(ListToolsRequestSchema, async () => ({
tools: [
{
name: 'list_vsls',
description: 'Get all VSLs to find VSL IDs for other operations',
inputSchema: {
type: 'object',
properties: {},
required: [],
},
},
{
name: 'get_vsl',
description: 'Get detailed info about a specific VSL',
inputSchema: {
type: 'object',
properties: {
vsl_id: { type: 'string', description: 'The VSL ID (UUID format)' },
},
required: ['vsl_id'],
},
},
{
name: 'get_available_times',
description: 'Check which time slots are available for booking on a specific date',
inputSchema: {
type: 'object',
properties: {
vsl_id: { type: 'string', description: 'The VSL ID' },
date: { type: 'string', description: 'Date in YYYY-MM-DD format' },
},
required: ['vsl_id', 'date'],
},
},
{
name: 'create_booking',
description: 'Create a new booking with optional auto-confirmation for instant Meet link',
inputSchema: {
type: 'object',
properties: {
vsl_id: { type: 'string', description: 'The VSL ID to book' },
customer_name: { type: 'string', description: "Customer's full name" },
customer_email: { type: 'string', description: "Customer's email" },
customer_phone: { type: 'string', description: "Customer's phone (optional)" },
booking_date: { type: 'string', description: 'Date in YYYY-MM-DD format' },
booking_time: { type: 'string', description: "Time in 12-hour format (e.g., '10:00 AM')" },
auto_confirm: { type: 'boolean', description: 'true = instant Meet link, false = pending', default: true },
},
required: ['vsl_id', 'customer_name', 'customer_email', 'booking_date', 'booking_time'],
},
},
{
name: 'list_bookings',
description: 'Get all bookings across all VSLs',
inputSchema: {
type: 'object',
properties: {},
required: [],
},
},
{
name: 'get_booking',
description: 'Get details of a specific booking by ID',
inputSchema: {
type: 'object',
properties: {
booking_id: { type: 'string', description: 'The booking ID (UUID format)' },
},
required: ['booking_id'],
},
},
{
name: 'get_waitlist',
description: 'Get waitlist entries for a VSL with pagination',
inputSchema: {
type: 'object',
properties: {
vsl_id: { type: 'string', description: 'The VSL ID' },
page: { type: 'integer', description: 'Page number (default: 1)', default: 1 },
limit: { type: 'integer', description: 'Results per page (max: 50)', default: 50 },
},
required: ['vsl_id'],
},
},
],
}));
// Handle tool calls
this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
const { name, arguments: args } = request.params;
try {
switch (name) {
case 'list_vsls':
return { content: [{ type: 'text', text: JSON.stringify(await this.makeRequest('/vsls')) }] };
case 'get_vsl':
return { content: [{ type: 'text', text: JSON.stringify(await this.makeRequest(`/vsls/${args.vsl_id}`)) }] };
case 'get_available_times':
return { content: [{ type: 'text', text: JSON.stringify(await this.makeRequest(`/vsls/${args.vsl_id}/available-times?date=${args.date}`)) }] };
case 'create_booking':
return { content: [{ type: 'text', text: JSON.stringify(await this.makeRequest('/bookings', 'POST', args)) }] };
case 'list_bookings':
return { content: [{ type: 'text', text: JSON.stringify(await this.makeRequest('/bookings')) }] };
case 'get_booking':
return { content: [{ type: 'text', text: JSON.stringify(await this.makeRequest(`/bookings/${args.booking_id}`)) }] };
case 'get_waitlist':
const page = args.page || 1;
const limit = args.limit || 50;
return { content: [{ type: 'text', text: JSON.stringify(await this.makeRequest(`/vsls/${args.vsl_id}/waitlists?page=${page}&limit=${limit}`)) }] };
default:
throw new Error(`Unknown tool: ${name}`);
}
} catch (error) {
return {
content: [{ type: 'text', text: `Error: ${error.message}` }],
isError: true,
};
}
});
}
async run() {
const transport = new StdioServerTransport();
await this.server.connect(transport);
console.error('Epiphany MCP Server running on stdio');
}
}
const server = new EpiphanyMCPServer();
server.run().catch(console.error);