@easyfunnel/mcp 0.1.9 → 0.1.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +89 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -94,6 +94,14 @@ var ApiClient = class {
94
94
  body: JSON.stringify(config)
95
95
  });
96
96
  }
97
+ async getConversations(projectId, params) {
98
+ const searchParams = new URLSearchParams();
99
+ if (params.limit) searchParams.set("limit", params.limit.toString());
100
+ if (params.session_id) searchParams.set("session_id", params.session_id);
101
+ return this.request(
102
+ `/projects/${projectId}/conversations?${searchParams.toString()}`
103
+ );
104
+ }
97
105
  async queryEvents(projectId, params) {
98
106
  const searchParams = new URLSearchParams();
99
107
  searchParams.set("query_type", params.query_type);
@@ -2117,6 +2125,83 @@ The chat widget will appear as a floating bubble in the bottom-right corner of y
2117
2125
  };
2118
2126
  }
2119
2127
 
2128
+ // src/tools/query-conversations.ts
2129
+ var queryConversationsDefinition = {
2130
+ name: "query_conversations",
2131
+ description: "Read chat widget conversations from visitors. Lists recent conversations with previews, or fetches full message transcript for a specific session.",
2132
+ inputSchema: {
2133
+ type: "object",
2134
+ properties: {
2135
+ project_id: { type: "string", description: "Project ID" },
2136
+ session_id: {
2137
+ type: "string",
2138
+ description: "Specific chat session ID to fetch full transcript. If omitted, lists recent conversations."
2139
+ },
2140
+ limit: {
2141
+ type: "number",
2142
+ description: "Max conversations to return (default: 20, max: 50)"
2143
+ }
2144
+ },
2145
+ required: ["project_id"]
2146
+ }
2147
+ };
2148
+ async function queryConversations(client2, args) {
2149
+ const data = await client2.getConversations(args.project_id, {
2150
+ limit: args.limit,
2151
+ session_id: args.session_id
2152
+ });
2153
+ let output;
2154
+ if (args.session_id) {
2155
+ const s = data.session;
2156
+ output = `Conversation with ${s.user_email || "Anonymous (" + s.visitor_id.slice(0, 8) + ")"}
2157
+ `;
2158
+ output += `Country: ${s.country || "unknown"} | Device: ${s.device || "unknown"} | Browser: ${s.browser || "unknown"}
2159
+ `;
2160
+ output += `First page: ${s.first_page || "unknown"}
2161
+ `;
2162
+ output += `Started: ${s.created_at}
2163
+ `;
2164
+ output += `\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
2165
+
2166
+ `;
2167
+ for (const msg of data.messages || []) {
2168
+ const label = msg.role === "user" ? "\u{1F464} Visitor" : "\u{1F916} Assistant";
2169
+ output += `${label}:
2170
+ ${msg.content}
2171
+ `;
2172
+ if (msg.page_url) output += ` [on ${msg.page_url}]
2173
+ `;
2174
+ output += "\n";
2175
+ }
2176
+ if (!data.messages?.length) output += "No messages in this conversation.\n";
2177
+ } else {
2178
+ const sessions = data.sessions || [];
2179
+ output = `Chat conversations (${sessions.length} total):
2180
+
2181
+ `;
2182
+ for (const s of sessions) {
2183
+ const visitor = s.user_email || `Anonymous (${s.visitor_id.slice(0, 8)})`;
2184
+ const country = s.country || "??";
2185
+ const device = s.device || "?";
2186
+ output += `\u2022 ${visitor} \u2014 ${country}, ${device}, ${s.message_count} msgs
2187
+ `;
2188
+ output += ` ID: ${s.id}
2189
+ `;
2190
+ if (s.preview) output += ` "${s.preview}"
2191
+ `;
2192
+ output += ` First page: ${s.first_page || "?"} | Last active: ${s.last_message_at}
2193
+
2194
+ `;
2195
+ }
2196
+ if (sessions.length === 0) {
2197
+ output += "No conversations yet.\n";
2198
+ }
2199
+ }
2200
+ return {
2201
+ content: [{ type: "text", text: output }]
2202
+ };
2203
+ }
2204
+
2120
2205
  // src/index.ts
2121
2206
  var apiKey = process.env.EASYFUNNEL_API_KEY;
2122
2207
  if (!apiKey) {
@@ -2147,7 +2232,8 @@ server.setRequestHandler(import_types.ListToolsRequestSchema, async () => ({
2147
2232
  queryEventsDefinition,
2148
2233
  deleteFunnelDefinition,
2149
2234
  updateFunnelDefinition,
2150
- setupChatWidgetDefinition
2235
+ setupChatWidgetDefinition,
2236
+ queryConversationsDefinition
2151
2237
  ]
2152
2238
  }));
2153
2239
  server.setRequestHandler(import_types.CallToolRequestSchema, async (request) => {
@@ -2183,6 +2269,8 @@ server.setRequestHandler(import_types.CallToolRequestSchema, async (request) =>
2183
2269
  return updateFunnel(client, args);
2184
2270
  case "setup_chat_widget":
2185
2271
  return setupChatWidget(client, args);
2272
+ case "query_conversations":
2273
+ return queryConversations(client, args);
2186
2274
  default:
2187
2275
  throw new Error(`Unknown tool: ${name}`);
2188
2276
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@easyfunnel/mcp",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
4
4
  "description": "MCP server for easyfunnel.co — AI-powered analytics tools for Claude/Cursor",
5
5
  "main": "dist/index.js",
6
6
  "bin": {