@closedloop-ai/mcp-client 1.0.0

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 (3) hide show
  1. package/README.md +74 -0
  2. package/index.js +143 -0
  3. package/package.json +28 -0
package/README.md ADDED
@@ -0,0 +1,74 @@
1
+ # ClosedLoop MCP Server
2
+
3
+ A lightweight Model Context Protocol (MCP) server that provides AI clients with access to ClosedLoop customer feedback data.
4
+
5
+ ## Features
6
+
7
+ - **MCP Protocol Support**: Full MCP protocol implementation for AI client integration
8
+ - **API Key Authentication**: Secure team-based API key authentication
9
+ - **Team Isolation**: All data access is scoped to the team that owns the API key
10
+ - **Two Core Tools**:
11
+ - `list_insights`: Get customer insights with date range and pagination
12
+ - `get_insight_detail`: Get detailed information about specific insights
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ npm install -g @jirikobelka/server-closedloop
18
+ ```
19
+
20
+ ## Configuration
21
+
22
+ Set the following environment variables:
23
+
24
+ - `CLOSEDLOOP_API_KEY`: Your ClosedLoop API key (required)
25
+ - `CLOSEDLOOP_SERVER_URL`: Server URL (default: https://mcp.closedloop.sh)
26
+
27
+ ## Usage with Claude
28
+
29
+ Add this configuration to your Claude Desktop app:
30
+
31
+ ```json
32
+ {
33
+ "mcpServers": {
34
+ "closedloop": {
35
+ "command": "npx",
36
+ "args": ["@jirikobelka/server-closedloop"],
37
+ "env": {
38
+ "CLOSEDLOOP_API_KEY": "your-api-key-here",
39
+ "CLOSEDLOOP_SERVER_URL": "https://mcp.closedloop.sh"
40
+ }
41
+ }
42
+ }
43
+ }
44
+ ```
45
+
46
+ ## MCP Tools
47
+
48
+ ### list_insights
49
+ Retrieve customer insights with optional filtering and pagination.
50
+
51
+ **Parameters:**
52
+ - `date_from` (optional): Start date (YYYY-MM-DD)
53
+ - `date_to` (optional): End date (YYYY-MM-DD)
54
+ - `page` (optional): Page number (default: 1)
55
+ - `limit` (optional): Items per page (default: 20, max: 100)
56
+
57
+ ### get_insight_detail
58
+ Get detailed information about a specific insight item.
59
+
60
+ **Parameters:**
61
+ - `insight_id` (required): UUID of the insight item
62
+
63
+ ## Example Usage
64
+
65
+ Once configured, you can ask Claude questions like:
66
+
67
+ - "Show me all negative insights from last week"
68
+ - "What are the top customer insights this month?"
69
+ - "Find insights about the dashboard being confusing"
70
+ - "Give me insights on user onboarding issues"
71
+
72
+ ## License
73
+
74
+ MIT
package/index.js ADDED
@@ -0,0 +1,143 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { Server } = require('@modelcontextprotocol/sdk/server/index.js');
4
+ const { StdioServerTransport } = require('@modelcontextprotocol/sdk/server/stdio.js');
5
+ const { CallToolRequestSchema, ListToolsRequestSchema } = require('@modelcontextprotocol/sdk/types.js');
6
+ const axios = require('axios');
7
+
8
+ // Get configuration from environment
9
+ const CLOSEDLOOP_API_KEY = process.env.CLOSEDLOOP_API_KEY;
10
+ const CLOSEDLOOP_SERVER_URL = process.env.CLOSEDLOOP_SERVER_URL || 'https://mcp.closedloop.sh';
11
+
12
+ if (!CLOSEDLOOP_API_KEY) {
13
+ console.error('Error: CLOSEDLOOP_API_KEY environment variable is required');
14
+ process.exit(1);
15
+ }
16
+
17
+ // Create MCP server
18
+ const server = new Server(
19
+ {
20
+ name: 'closedloop-mcp-server',
21
+ version: '1.0.0',
22
+ description: 'Provides access to ClosedLoop AI product feedback data and insights.',
23
+ },
24
+ {
25
+ capabilities: {
26
+ tools: {}
27
+ }
28
+ }
29
+ );
30
+
31
+ // Define available tools
32
+ const tools = [
33
+ {
34
+ name: 'list_insights',
35
+ description: 'Retrieve customer insights with optional filtering and pagination',
36
+ inputSchema: {
37
+ type: 'object',
38
+ properties: {
39
+ date_from: {
40
+ type: 'string',
41
+ description: 'Start date for insights (YYYY-MM-DD)',
42
+ format: 'date'
43
+ },
44
+ date_to: {
45
+ type: 'string',
46
+ description: 'End date for insights (YYYY-MM-DD)',
47
+ format: 'date'
48
+ },
49
+ page: {
50
+ type: 'integer',
51
+ description: 'Page number (default: 1)',
52
+ minimum: 1
53
+ },
54
+ limit: {
55
+ type: 'integer',
56
+ description: 'Insight items per page (default: 20, max: 100)',
57
+ minimum: 1,
58
+ maximum: 100
59
+ }
60
+ }
61
+ }
62
+ },
63
+ {
64
+ name: 'get_insight_detail',
65
+ description: 'Get detailed information about a specific insight item',
66
+ inputSchema: {
67
+ type: 'object',
68
+ properties: {
69
+ insight_id: {
70
+ type: 'string',
71
+ description: 'UUID of the insight item'
72
+ }
73
+ },
74
+ required: ['insight_id']
75
+ }
76
+ }
77
+ ];
78
+
79
+ // List tools handler
80
+ server.setRequestHandler(ListToolsRequestSchema, async () => {
81
+ return { tools };
82
+ });
83
+
84
+ // Call tool handler
85
+ server.setRequestHandler(CallToolRequestSchema, async (request) => {
86
+ const { name, arguments: args } = request.params;
87
+
88
+ try {
89
+ const headers = {
90
+ 'Authorization': `Bearer ${CLOSEDLOOP_API_KEY}`,
91
+ 'Content-Type': 'application/json'
92
+ };
93
+
94
+ let response;
95
+
96
+ switch (name) {
97
+ case 'list_insights':
98
+ response = await axios.get(`${CLOSEDLOOP_SERVER_URL}/feedbacks`, {
99
+ headers,
100
+ params: args
101
+ });
102
+ break;
103
+
104
+ case 'get_insight_detail':
105
+ if (!args.insight_id) {
106
+ throw new Error('insight_id is required');
107
+ }
108
+ response = await axios.get(`${CLOSEDLOOP_SERVER_URL}/feedbacks/${args.insight_id}`, {
109
+ headers
110
+ });
111
+ break;
112
+
113
+ default:
114
+ throw new Error(`Unknown tool: ${name}`);
115
+ }
116
+
117
+ return {
118
+ content: [
119
+ {
120
+ type: 'text',
121
+ text: JSON.stringify(response.data, null, 2)
122
+ }
123
+ ]
124
+ };
125
+
126
+ } catch (error) {
127
+ return {
128
+ content: [
129
+ {
130
+ type: 'text',
131
+ text: `Error: ${error.message}`
132
+ }
133
+ ],
134
+ isError: true
135
+ };
136
+ }
137
+ });
138
+
139
+ // Start the server
140
+ const transport = new StdioServerTransport();
141
+ server.connect(transport);
142
+
143
+ console.error('ClosedLoop MCP Server started');
package/package.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "@closedloop-ai/mcp-client",
3
+ "version": "1.0.0",
4
+ "description": "ClosedLoop MCP Server for AI client integration",
5
+ "main": "index.js",
6
+ "bin": {
7
+ "closedloop-mcp": "./index.js"
8
+ },
9
+ "scripts": {
10
+ "start": "node index.js"
11
+ },
12
+ "dependencies": {
13
+ "@modelcontextprotocol/sdk": "^0.5.0",
14
+ "axios": "^1.6.0"
15
+ },
16
+ "engines": {
17
+ "node": ">=18.0.0"
18
+ },
19
+ "keywords": [
20
+ "mcp",
21
+ "ai",
22
+ "closedloop",
23
+ "feedback",
24
+ "analytics"
25
+ ],
26
+ "author": "ClosedLoop",
27
+ "license": "MIT"
28
+ }