@appsai/mcp-server 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.
- package/README.md +74 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +108 -0
- package/dist/index.js.map +1 -0
- package/dist/tools.d.ts +22 -0
- package/dist/tools.js +183 -0
- package/dist/tools.js.map +1 -0
- package/dist/utils/parse.d.ts +23 -0
- package/dist/utils/parse.js +51 -0
- package/dist/utils/parse.js.map +1 -0
- package/package.json +55 -0
package/README.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# AppsAI MCP Server
|
|
2
|
+
|
|
3
|
+
The official Model Context Protocol (MCP) server for AppsAI. Connect Claude Code and other MCP-compatible tools to your AppsAI projects.
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
### 1. Get an API Key
|
|
8
|
+
|
|
9
|
+
1. Sign in to [AppsAI](https://appsai.com)
|
|
10
|
+
2. Go to **Settings → Billing** and scroll to **API Keys**
|
|
11
|
+
3. Click **Create Key** and copy it (shown only once)
|
|
12
|
+
|
|
13
|
+
### 2. Add to Claude Code
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
claude mcp add appsai --env APPSAI_API_KEY=appsai_xxxxx -- npx @appsai/mcp-server
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### 3. Start Building
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
"List my projects"
|
|
23
|
+
"Create a new project using the nextjs-starter template"
|
|
24
|
+
"Show the files in project abc123"
|
|
25
|
+
"Add a button component to app/page.tsx"
|
|
26
|
+
"Deploy the frontend"
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Features
|
|
30
|
+
|
|
31
|
+
- **87 Tools** across 8 categories
|
|
32
|
+
- **Project Management** — Create, list, delete projects
|
|
33
|
+
- **Frontend Development** — Edit React/Next.js components, styles, dependencies
|
|
34
|
+
- **Backend Development** — Manage Parse Server cloud functions
|
|
35
|
+
- **Deployment** — Deploy to AWS with one command
|
|
36
|
+
- **AWS Infrastructure** — Run any AWS CLI command, manage CloudFormation
|
|
37
|
+
- **MongoDB Atlas** — Database and cluster management
|
|
38
|
+
- **Pay-as-you-go** — Uses your AppsAI credit balance
|
|
39
|
+
|
|
40
|
+
## Tool Categories
|
|
41
|
+
|
|
42
|
+
| Category | Tools | Description |
|
|
43
|
+
|----------|-------|-------------|
|
|
44
|
+
| Project | 5 | Create, list, manage projects |
|
|
45
|
+
| Canvas | 25 | Frontend React/Next.js development |
|
|
46
|
+
| Server | 6 | Backend Parse Server development |
|
|
47
|
+
| System | 5 | Deployment & environment |
|
|
48
|
+
| AWS | 12 | Infrastructure via CLI + CloudFormation |
|
|
49
|
+
| MongoDB | 18 | Database operations |
|
|
50
|
+
| Agent | 9 | AI prompt management |
|
|
51
|
+
| Shared | 7 | Cross-category communication |
|
|
52
|
+
|
|
53
|
+
## Billing
|
|
54
|
+
|
|
55
|
+
Usage is charged to your AppsAI credit balance:
|
|
56
|
+
- **File operations** — Free
|
|
57
|
+
- **AI generation** — Model-based pricing
|
|
58
|
+
- **AWS operations** — Based on resources
|
|
59
|
+
- **MongoDB** — Based on cluster tier
|
|
60
|
+
- **Deployment** — Per deployment
|
|
61
|
+
|
|
62
|
+
## Environment Variables
|
|
63
|
+
|
|
64
|
+
| Variable | Required | Description |
|
|
65
|
+
|----------|----------|-------------|
|
|
66
|
+
| `APPSAI_API_KEY` | Yes | Your API key from Settings → Billing |
|
|
67
|
+
|
|
68
|
+
## Documentation
|
|
69
|
+
|
|
70
|
+
Full documentation: [appsai.com/docs/mcp](https://appsai.com/docs/mcp)
|
|
71
|
+
|
|
72
|
+
## License
|
|
73
|
+
|
|
74
|
+
MIT
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* AppsAI MCP Server
|
|
4
|
+
*
|
|
5
|
+
* Exposes AppsAI tools to LLMs via the Model Context Protocol.
|
|
6
|
+
* Supports all AI tool categories: project, canvas, server, system, aws, mongodb, agent.
|
|
7
|
+
*/
|
|
8
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
9
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
10
|
+
import { CallToolRequestSchema, ListToolsRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
11
|
+
import * as dotenv from 'dotenv';
|
|
12
|
+
import { getAllTools, executeToolCall } from './tools.js';
|
|
13
|
+
import { validateAPIKey, initializeParse } from './utils/parse.js';
|
|
14
|
+
// Load environment variables
|
|
15
|
+
dotenv.config();
|
|
16
|
+
// Get API key from environment
|
|
17
|
+
const API_KEY = process.env.APPSAI_API_KEY;
|
|
18
|
+
// Cached user ID after validation
|
|
19
|
+
let cachedUserId = null;
|
|
20
|
+
/**
|
|
21
|
+
* Validate the API key and cache the user ID
|
|
22
|
+
*/
|
|
23
|
+
async function ensureAuthenticated() {
|
|
24
|
+
if (cachedUserId) {
|
|
25
|
+
return cachedUserId;
|
|
26
|
+
}
|
|
27
|
+
if (!API_KEY) {
|
|
28
|
+
throw new Error('APPSAI_API_KEY environment variable is required');
|
|
29
|
+
}
|
|
30
|
+
const result = await validateAPIKey(API_KEY);
|
|
31
|
+
if (!result.valid) {
|
|
32
|
+
throw new Error(result.error || 'Invalid API key');
|
|
33
|
+
}
|
|
34
|
+
cachedUserId = result.userId;
|
|
35
|
+
return cachedUserId;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Create and configure the MCP server
|
|
39
|
+
*/
|
|
40
|
+
async function createServer() {
|
|
41
|
+
// Initialize Parse SDK
|
|
42
|
+
initializeParse();
|
|
43
|
+
const server = new Server({
|
|
44
|
+
name: 'appsai',
|
|
45
|
+
version: '1.0.0',
|
|
46
|
+
}, {
|
|
47
|
+
capabilities: {
|
|
48
|
+
tools: {},
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
// Handle tool listing
|
|
52
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
53
|
+
try {
|
|
54
|
+
// Validate API key on first request
|
|
55
|
+
await ensureAuthenticated();
|
|
56
|
+
const tools = await getAllTools();
|
|
57
|
+
console.error(`[MCP] Returning ${tools.length} tools`);
|
|
58
|
+
return { tools };
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
62
|
+
console.error(`[MCP] Error listing tools: ${message}`);
|
|
63
|
+
// Return empty tools if auth fails
|
|
64
|
+
return { tools: [] };
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
// Handle tool calls
|
|
68
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
69
|
+
const { name, arguments: args } = request.params;
|
|
70
|
+
console.error(`[MCP] Tool call: ${name}`);
|
|
71
|
+
try {
|
|
72
|
+
// Ensure authenticated
|
|
73
|
+
const userId = await ensureAuthenticated();
|
|
74
|
+
// Execute the tool
|
|
75
|
+
const result = await executeToolCall(name, args || {}, userId);
|
|
76
|
+
return result;
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
80
|
+
console.error(`[MCP] Error executing ${name}: ${message}`);
|
|
81
|
+
return {
|
|
82
|
+
content: [{ type: 'text', text: `Authentication error: ${message}` }],
|
|
83
|
+
isError: true,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
return server;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Main entry point
|
|
91
|
+
*/
|
|
92
|
+
async function main() {
|
|
93
|
+
console.error('[MCP] Starting AppsAI MCP Server...');
|
|
94
|
+
try {
|
|
95
|
+
const server = await createServer();
|
|
96
|
+
const transport = new StdioServerTransport();
|
|
97
|
+
await server.connect(transport);
|
|
98
|
+
console.error('[MCP] Server connected and ready');
|
|
99
|
+
}
|
|
100
|
+
catch (error) {
|
|
101
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
102
|
+
console.error(`[MCP] Fatal error: ${message}`);
|
|
103
|
+
process.exit(1);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
// Run the server
|
|
107
|
+
main();
|
|
108
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;GAKG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnE,6BAA6B;AAC7B,MAAM,CAAC,MAAM,EAAE,CAAC;AAEhB,+BAA+B;AAC/B,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC;AAE3C,kCAAkC;AAClC,IAAI,YAAY,GAAkB,IAAI,CAAC;AAEvC;;GAEG;AACH,KAAK,UAAU,mBAAmB;IAChC,IAAI,YAAY,EAAE,CAAC;QACjB,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;IACrE,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,OAAO,CAAC,CAAC;IAE7C,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QAClB,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,K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CAAC;AAED,iBAAiB;AACjB,IAAI,EAAE,CAAC"}
|
package/dist/tools.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Tool Registry
|
|
3
|
+
*
|
|
4
|
+
* Converts OpenAI-style tool definitions to MCP format and routes tool calls.
|
|
5
|
+
*/
|
|
6
|
+
import type { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
7
|
+
export type ToolCategory = 'project' | 'canvas' | 'server' | 'system' | 'aws' | 'mongodb' | 'agent' | 'shared';
|
|
8
|
+
/**
|
|
9
|
+
* Get all MCP tools
|
|
10
|
+
* Fetches tool definitions from Parse Server
|
|
11
|
+
*/
|
|
12
|
+
export declare function getAllTools(): Promise<Tool[]>;
|
|
13
|
+
/**
|
|
14
|
+
* Execute a tool call
|
|
15
|
+
*/
|
|
16
|
+
export declare function executeToolCall(toolName: string, args: Record<string, unknown>, userId: string): Promise<{
|
|
17
|
+
content: Array<{
|
|
18
|
+
type: 'text';
|
|
19
|
+
text: string;
|
|
20
|
+
}>;
|
|
21
|
+
isError?: boolean;
|
|
22
|
+
}>;
|
package/dist/tools.js
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Tool Registry
|
|
3
|
+
*
|
|
4
|
+
* Converts OpenAI-style tool definitions to MCP format and routes tool calls.
|
|
5
|
+
*/
|
|
6
|
+
import { runCloudFunction } from './utils/parse.js';
|
|
7
|
+
/**
|
|
8
|
+
* Convert an OpenAI-style tool to MCP format
|
|
9
|
+
*/
|
|
10
|
+
function convertToMCPTool(tool, category) {
|
|
11
|
+
return {
|
|
12
|
+
name: `${category}_${tool.name}`,
|
|
13
|
+
description: tool.description,
|
|
14
|
+
inputSchema: tool.parameters,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
// Project management tools (new for MCP)
|
|
18
|
+
const projectTools = [
|
|
19
|
+
{
|
|
20
|
+
type: 'function',
|
|
21
|
+
name: 'LIST_PROJECTS',
|
|
22
|
+
description: 'List all projects owned by or shared with the authenticated user',
|
|
23
|
+
parameters: {
|
|
24
|
+
type: 'object',
|
|
25
|
+
properties: {
|
|
26
|
+
skip: { type: 'number', description: 'Number of projects to skip (for pagination)' },
|
|
27
|
+
limit: { type: 'number', description: 'Maximum number of projects to return (default 20)' },
|
|
28
|
+
},
|
|
29
|
+
required: [],
|
|
30
|
+
additionalProperties: false,
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
type: 'function',
|
|
35
|
+
name: 'GET_TEMPLATES',
|
|
36
|
+
description: 'Get available starter templates for creating new projects',
|
|
37
|
+
parameters: {
|
|
38
|
+
type: 'object',
|
|
39
|
+
properties: {},
|
|
40
|
+
required: [],
|
|
41
|
+
additionalProperties: false,
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
type: 'function',
|
|
46
|
+
name: 'CREATE_PROJECT',
|
|
47
|
+
description: 'Create a new project from a starter template',
|
|
48
|
+
parameters: {
|
|
49
|
+
type: 'object',
|
|
50
|
+
properties: {
|
|
51
|
+
templateS3Key: { type: 'string', description: 'S3 key of the starter template to use' },
|
|
52
|
+
},
|
|
53
|
+
required: ['templateS3Key'],
|
|
54
|
+
additionalProperties: false,
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
type: 'function',
|
|
59
|
+
name: 'GET_PROJECT_DETAILS',
|
|
60
|
+
description: 'Get detailed information about a specific project',
|
|
61
|
+
parameters: {
|
|
62
|
+
type: 'object',
|
|
63
|
+
properties: {
|
|
64
|
+
projectId: { type: 'string', description: 'The project ID' },
|
|
65
|
+
},
|
|
66
|
+
required: ['projectId'],
|
|
67
|
+
additionalProperties: false,
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
type: 'function',
|
|
72
|
+
name: 'DELETE_PROJECT',
|
|
73
|
+
description: 'Delete a project (owner only). This action cannot be undone.',
|
|
74
|
+
parameters: {
|
|
75
|
+
type: 'object',
|
|
76
|
+
properties: {
|
|
77
|
+
projectId: { type: 'string', description: 'The project ID to delete' },
|
|
78
|
+
},
|
|
79
|
+
required: ['projectId'],
|
|
80
|
+
additionalProperties: false,
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
];
|
|
84
|
+
// Map project tool names to cloud functions
|
|
85
|
+
const projectToolToCloudFunction = {
|
|
86
|
+
LIST_PROJECTS: 'getUserProjects',
|
|
87
|
+
GET_TEMPLATES: 'getTemplates',
|
|
88
|
+
CREATE_PROJECT: 'createProject',
|
|
89
|
+
GET_PROJECT_DETAILS: 'getProjectDetails',
|
|
90
|
+
DELETE_PROJECT: 'deleteProject',
|
|
91
|
+
};
|
|
92
|
+
// Map category tools to cloud functions
|
|
93
|
+
const categoryToolToCloudFunction = {
|
|
94
|
+
project: 'executeProjectTool',
|
|
95
|
+
canvas: 'executeMCPTool',
|
|
96
|
+
server: 'executeMCPTool',
|
|
97
|
+
system: 'executeMCPTool',
|
|
98
|
+
aws: 'executeMCPTool',
|
|
99
|
+
mongodb: 'executeMCPTool',
|
|
100
|
+
agent: 'executeMCPTool',
|
|
101
|
+
shared: 'executeMCPTool',
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Get all MCP tools
|
|
105
|
+
* Fetches tool definitions from Parse Server
|
|
106
|
+
*/
|
|
107
|
+
export async function getAllTools() {
|
|
108
|
+
const tools = [];
|
|
109
|
+
// Add project tools (defined locally)
|
|
110
|
+
for (const tool of projectTools) {
|
|
111
|
+
tools.push(convertToMCPTool(tool, 'project'));
|
|
112
|
+
}
|
|
113
|
+
// Fetch category tools from backend
|
|
114
|
+
try {
|
|
115
|
+
const result = await runCloudFunction('getMCPToolDefinitions', {});
|
|
116
|
+
for (const [category, categoryTools] of Object.entries(result.tools)) {
|
|
117
|
+
for (const tool of categoryTools) {
|
|
118
|
+
tools.push(convertToMCPTool(tool, category));
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
catch (error) {
|
|
123
|
+
console.error('[Tools] Failed to fetch tool definitions from backend:', error);
|
|
124
|
+
// Return just project tools if backend is unavailable
|
|
125
|
+
}
|
|
126
|
+
return tools;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Execute a tool call
|
|
130
|
+
*/
|
|
131
|
+
export async function executeToolCall(toolName, args, userId) {
|
|
132
|
+
// Parse tool name: category_TOOL_NAME
|
|
133
|
+
const underscoreIndex = toolName.indexOf('_');
|
|
134
|
+
if (underscoreIndex === -1) {
|
|
135
|
+
return {
|
|
136
|
+
content: [{ type: 'text', text: `Invalid tool name format: ${toolName}` }],
|
|
137
|
+
isError: true,
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
const category = toolName.substring(0, underscoreIndex);
|
|
141
|
+
const name = toolName.substring(underscoreIndex + 1);
|
|
142
|
+
try {
|
|
143
|
+
let result;
|
|
144
|
+
if (category === 'project') {
|
|
145
|
+
// Handle project tools with direct cloud function mapping
|
|
146
|
+
const cloudFunction = projectToolToCloudFunction[name];
|
|
147
|
+
if (!cloudFunction) {
|
|
148
|
+
return {
|
|
149
|
+
content: [{ type: 'text', text: `Unknown project tool: ${name}` }],
|
|
150
|
+
isError: true,
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
result = await runCloudFunction(cloudFunction, { ...args, _mcpUserId: userId });
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
// Handle category tools via unified MCP executor
|
|
157
|
+
result = await runCloudFunction('executeMCPTool', {
|
|
158
|
+
category,
|
|
159
|
+
tool: name,
|
|
160
|
+
params: args,
|
|
161
|
+
userId,
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
return {
|
|
165
|
+
content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
catch (error) {
|
|
169
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
170
|
+
const code = error?.code;
|
|
171
|
+
if (code === 402) {
|
|
172
|
+
return {
|
|
173
|
+
content: [{ type: 'text', text: 'Insufficient credits. Please add funds at appsai.com/billing' }],
|
|
174
|
+
isError: true,
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
return {
|
|
178
|
+
content: [{ type: 'text', text: `Error executing ${toolName}: ${message}` }],
|
|
179
|
+
isError: true,
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
//# sourceMappingURL=tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAkBpD;;GAEG;AACH,SAAS,gBAAgB,CAAC,IAAY,EAAE,QAAsB;IAC5D,OAAO;QACL,IAAI,EAAE,GAAG,QAAQ,IAAI,IAAI,CAAC,IAAI,EAAE;QAChC,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,WAAW,EAAE,IAAI,CAAC,UAAiC;KACpD,CAAC;AACJ,CAAC;AAED,yCAAyC;AACzC,MAAM,YAAY,GAAa;IAC7B;QACE,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,eAAe;QACrB,WAAW,EAAE,kEAAkE;QAC/E,UAAU,EAAE;YACV,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,6CAA6C,EAAE;gBACpF,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,mDAAmD,EAAE;aAC5F;YACD,QAAQ,EAAE,EAAE;YACZ,oBAAoB,EAAE,KAAK;SAC5B;KACF;IACD;QACE,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,eAAe;QACrB,WAAW,EAAE,2DAA2D;QACxE,UAAU,EAAE;YACV,IAAI,EAAE,Q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AAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC;QACzE,MAAM,IAAI,GAAI,KAA2B,EAAE,IAAI,CAAC;QAEhD,IAAI,IAAI,KAAK,GAAG,EAAE,CAAC;YACjB,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,8DAA8D,EAAE,CAAC;gBACjG,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;QAED,OAAO;YACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,mBAAmB,QAAQ,KAAK,OAAO,EAAE,EAAE,CAAC;YAC5E,OAAO,EAAE,IAAI;SACd,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse SDK Client Setup
|
|
3
|
+
*
|
|
4
|
+
* Initializes Parse SDK for communicating with the Parse Server.
|
|
5
|
+
*/
|
|
6
|
+
import Parse from 'parse/node.js';
|
|
7
|
+
/**
|
|
8
|
+
* Initialize Parse SDK with server configuration
|
|
9
|
+
*/
|
|
10
|
+
export declare function initializeParse(): void;
|
|
11
|
+
/**
|
|
12
|
+
* Run a Parse Cloud function
|
|
13
|
+
*/
|
|
14
|
+
export declare function runCloudFunction<T = unknown>(functionName: string, params: Record<string, unknown>, sessionToken?: string): Promise<T>;
|
|
15
|
+
/**
|
|
16
|
+
* Validate an API key and get the associated user ID
|
|
17
|
+
*/
|
|
18
|
+
export declare function validateAPIKey(apiKey: string): Promise<{
|
|
19
|
+
valid: boolean;
|
|
20
|
+
userId?: string;
|
|
21
|
+
error?: string;
|
|
22
|
+
}>;
|
|
23
|
+
export { Parse };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse SDK Client Setup
|
|
3
|
+
*
|
|
4
|
+
* Initializes Parse SDK for communicating with the Parse Server.
|
|
5
|
+
*/
|
|
6
|
+
import Parse from 'parse/node.js';
|
|
7
|
+
let initialized = false;
|
|
8
|
+
/**
|
|
9
|
+
* Initialize Parse SDK with server configuration
|
|
10
|
+
*/
|
|
11
|
+
export function initializeParse() {
|
|
12
|
+
if (initialized)
|
|
13
|
+
return;
|
|
14
|
+
const serverUrl = process.env.PARSE_SERVER_URL || 'https://internal.appsai.com/server';
|
|
15
|
+
const appId = process.env.PARSE_APP_ID || 'Rv4CcqHMjTcjAzSDb6vVMnw0Yp99ZQ5Wrvh80PUI';
|
|
16
|
+
const masterKey = process.env.PARSE_MASTER_KEY;
|
|
17
|
+
Parse.initialize(appId);
|
|
18
|
+
Parse.serverURL = serverUrl;
|
|
19
|
+
if (masterKey) {
|
|
20
|
+
Parse.masterKey = masterKey;
|
|
21
|
+
}
|
|
22
|
+
initialized = true;
|
|
23
|
+
console.error(`[Parse] Initialized with server: ${serverUrl}`);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Run a Parse Cloud function
|
|
27
|
+
*/
|
|
28
|
+
export async function runCloudFunction(functionName, params, sessionToken) {
|
|
29
|
+
initializeParse();
|
|
30
|
+
const options = {};
|
|
31
|
+
if (sessionToken) {
|
|
32
|
+
options.sessionToken = sessionToken;
|
|
33
|
+
}
|
|
34
|
+
return Parse.Cloud.run(functionName, params, options);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Validate an API key and get the associated user ID
|
|
38
|
+
*/
|
|
39
|
+
export async function validateAPIKey(apiKey) {
|
|
40
|
+
initializeParse();
|
|
41
|
+
try {
|
|
42
|
+
const result = await Parse.Cloud.run('validateMCPAPIKey', { apiKey }, { useMasterKey: true });
|
|
43
|
+
return result;
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
47
|
+
return { valid: false, error: message };
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
export { Parse };
|
|
51
|
+
//# sourceMappingURL=parse.js.map
|
|
@@ -0,0 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,CAAC,mBAAmB,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,CAI3F,CAAC;QACF,OAAO,MAAM,CAAC;IAChB,CAAC;IAAC,OAAO,KAAc,EAAE,CAAC;QACxB,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC;QACzE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;IAC1C,CAAC;AACH,CAAC;AAED,OAAO,EAAE,KAAK,EAAE,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@appsai/mcp-server",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Official MCP server for AppsAI - connect Claude Code to your AppsAI projects",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"appsai-mcp": "dist/index.js"
|
|
9
|
+
},
|
|
10
|
+
"engines": {
|
|
11
|
+
"node": ">=18.0.0"
|
|
12
|
+
},
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "tsc",
|
|
15
|
+
"start": "node dist/index.js",
|
|
16
|
+
"dev": "tsc --watch",
|
|
17
|
+
"prepublishOnly": "npm run build"
|
|
18
|
+
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
21
|
+
"dotenv": "^16.0.1",
|
|
22
|
+
"parse": "^6.1.1"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@types/node": "^18.11.18",
|
|
26
|
+
"@types/parse": "^3.0.9",
|
|
27
|
+
"typescript": "^5.0.0"
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"dist",
|
|
31
|
+
"README.md"
|
|
32
|
+
],
|
|
33
|
+
"keywords": [
|
|
34
|
+
"mcp",
|
|
35
|
+
"appsai",
|
|
36
|
+
"ai",
|
|
37
|
+
"llm",
|
|
38
|
+
"claude",
|
|
39
|
+
"model-context-protocol",
|
|
40
|
+
"react",
|
|
41
|
+
"nextjs",
|
|
42
|
+
"aws",
|
|
43
|
+
"mongodb"
|
|
44
|
+
],
|
|
45
|
+
"author": "AppsAI",
|
|
46
|
+
"license": "MIT",
|
|
47
|
+
"homepage": "https://appsai.com/docs/mcp",
|
|
48
|
+
"repository": {
|
|
49
|
+
"type": "git",
|
|
50
|
+
"url": "https://github.com/appsai/mcp-server"
|
|
51
|
+
},
|
|
52
|
+
"bugs": {
|
|
53
|
+
"url": "https://github.com/appsai/mcp-server/issues"
|
|
54
|
+
}
|
|
55
|
+
}
|