@catchmexz/fedin-vibe-mcp-server 0.1.13 → 0.1.14
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/dist/common/utils.js +2 -1
- package/dist/operations/supabase/deployEdgeFunction.js +27 -0
- package/dist/operations/supabase/index.js +2 -0
- package/dist/operations/supabase/listEdgeFunctions.js +31 -0
- package/dist/operations/supabase/types.js +13 -0
- package/dist/tool-handlers/deploy.js +11 -5
- package/dist/tool-handlers/index.js +3 -1
- package/dist/tool-handlers/supabase.js +22 -0
- package/dist/tool-registry/index.js +2 -0
- package/dist/tool-registry/supabase.js +37 -0
- package/package.json +5 -3
package/dist/common/utils.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { getUserAgent } from "universal-user-agent";
|
|
2
2
|
import { createYunxiaoError } from "./errors.js";
|
|
3
3
|
import { VERSION } from "./version.js";
|
|
4
|
-
import fs from
|
|
4
|
+
import fs from "fs";
|
|
5
5
|
import path from "path";
|
|
6
6
|
const DEFAULT_YUNXIAO_API_BASE_URL = "https://openapi-rdc.aliyuncs.com";
|
|
7
|
+
export const FEDIN_BACKEND_API_BASE_URL = "https://backend.api.fedin.cn";
|
|
7
8
|
/**
|
|
8
9
|
* Get the Yunxiao API base URL from environment variables or use the default
|
|
9
10
|
* @returns The Yunxiao API base URL
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { FEDIN_BACKEND_API_BASE_URL } from "../../common/utils.js";
|
|
2
|
+
import axios from "axios";
|
|
3
|
+
export async function deployEdgeFunctionFunc(projectId, name, content) {
|
|
4
|
+
const schema = projectId;
|
|
5
|
+
try {
|
|
6
|
+
const response = await axios.post(`${FEDIN_BACKEND_API_BASE_URL}/api/deno/deploy`, {
|
|
7
|
+
schema,
|
|
8
|
+
functionName: name,
|
|
9
|
+
codeContent: content
|
|
10
|
+
});
|
|
11
|
+
if (response.status === 200 && response.data?.code === 200) {
|
|
12
|
+
return {
|
|
13
|
+
name: response.data.data.functionName,
|
|
14
|
+
functionRequestUrl: response.data.data.apiRequestPath,
|
|
15
|
+
indexFilePath: response.data.data.indexFilePath
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
const errorMessage = response.data?.message || "deploy edge function failed";
|
|
20
|
+
throw new Error(errorMessage);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
const errorMessage = error.message || "deploy edge function failed";
|
|
25
|
+
throw new Error(errorMessage);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { FEDIN_BACKEND_API_BASE_URL } from "../../common/utils.js";
|
|
2
|
+
import axios from "axios";
|
|
3
|
+
export async function listEdgeFunctionsFunc(projectId) {
|
|
4
|
+
const schema = projectId;
|
|
5
|
+
try {
|
|
6
|
+
const response = await axios.get(`${FEDIN_BACKEND_API_BASE_URL}/api/deno/list`, {
|
|
7
|
+
params: {
|
|
8
|
+
schema
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
if (response.status === 200 && response.data?.code === 200) {
|
|
12
|
+
return response.data.data.map((i) => {
|
|
13
|
+
const functionRequestUrl = i.apiRequestPath;
|
|
14
|
+
return {
|
|
15
|
+
name: i.functionName,
|
|
16
|
+
functionRequestUrl,
|
|
17
|
+
indexFilePath: i.indexFilePath,
|
|
18
|
+
functionContent: i.codeContent
|
|
19
|
+
};
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
const errorMessage = response.data?.message || "get edge functions failed";
|
|
24
|
+
throw new Error(errorMessage);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
const errorMessage = error.message || "get edge functions failed";
|
|
29
|
+
throw new Error(errorMessage);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const ListEdgeFunctions = z.object({
|
|
3
|
+
projectId: z
|
|
4
|
+
.string()
|
|
5
|
+
.describe("Project ID. If not specified by the user, reads projectName from package.json as the project ID")
|
|
6
|
+
});
|
|
7
|
+
export const DeployEdgeFunction = z.object({
|
|
8
|
+
projectId: z
|
|
9
|
+
.string()
|
|
10
|
+
.describe("Project ID. If not specified by the user, reads projectName from package.json as the project ID"),
|
|
11
|
+
name: z.string().describe("The name of the function"),
|
|
12
|
+
content: z.string().describe("The content of the function")
|
|
13
|
+
});
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import { DeployInputSchema } from "../tool-registry/deploy.js";
|
|
2
2
|
import { runDeployTool } from "../operations/deploy/deploy.js";
|
|
3
3
|
export const handleDeployTools = async (request) => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
switch (request.params.name) {
|
|
5
|
+
case "deploy": {
|
|
6
|
+
const args = DeployInputSchema.parse(request.params.arguments);
|
|
7
|
+
return runDeployTool({
|
|
8
|
+
path: args.path,
|
|
9
|
+
message: args.message
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
default:
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
9
15
|
};
|
|
@@ -2,13 +2,15 @@ import { handleCodeManagementTools } from "./code-management.js";
|
|
|
2
2
|
import { handleOrganizationTools } from "./organization.js";
|
|
3
3
|
import { handleMiniprogramTools } from "./miniprogram.js";
|
|
4
4
|
import { handleDeployTools } from "./deploy.js";
|
|
5
|
+
import { handleSupabaseTools } from "./supabase.js";
|
|
5
6
|
export const handleToolRequest = async (request) => {
|
|
6
7
|
// Try each handler in sequence until one returns a result
|
|
7
8
|
const handlers = [
|
|
8
9
|
handleCodeManagementTools,
|
|
9
10
|
handleOrganizationTools,
|
|
10
11
|
handleDeployTools,
|
|
11
|
-
|
|
12
|
+
handleSupabaseTools,
|
|
13
|
+
handleMiniprogramTools
|
|
12
14
|
];
|
|
13
15
|
for (const handler of handlers) {
|
|
14
16
|
const result = await handler(request);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as types from "../operations/supabase/types.js";
|
|
2
|
+
import * as supabase from "../operations/supabase/index.js";
|
|
3
|
+
export const handleSupabaseTools = async (request) => {
|
|
4
|
+
switch (request.params.name) {
|
|
5
|
+
case "list_edge_functions": {
|
|
6
|
+
const args = types.ListEdgeFunctions.parse(request.params.arguments);
|
|
7
|
+
const functions = await supabase.listEdgeFunctionsFunc(args.projectId);
|
|
8
|
+
return {
|
|
9
|
+
content: [{ type: "text", text: JSON.stringify(functions, null, 2) }]
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
case "deploy_edge_function": {
|
|
13
|
+
const args = types.DeployEdgeFunction.parse(request.params.arguments);
|
|
14
|
+
const functions = await supabase.deployEdgeFunctionFunc(args.projectId, args.name, args.content);
|
|
15
|
+
return {
|
|
16
|
+
content: [{ type: "text", text: JSON.stringify(functions, null, 2) }]
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
default:
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
@@ -2,9 +2,11 @@ import { getCodeManagementTools } from "./code-management.js";
|
|
|
2
2
|
import { getOrganizationTools } from "./organization.js";
|
|
3
3
|
import { getMiniprogramTools } from "./miniprogram.js";
|
|
4
4
|
import { getDeployTools } from "./deploy.js";
|
|
5
|
+
import { getSupabaseTools } from "./supabase.js";
|
|
5
6
|
export const getAllTools = () => [
|
|
6
7
|
...getCodeManagementTools(),
|
|
7
8
|
...getOrganizationTools(),
|
|
8
9
|
...getDeployTools(),
|
|
9
10
|
...getMiniprogramTools(),
|
|
11
|
+
...getSupabaseTools(),
|
|
10
12
|
];
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { zodToJsonSchema } from "zod-to-json-schema";
|
|
2
|
+
import * as types from "../operations/supabase/types.js";
|
|
3
|
+
import { codeBlock } from 'common-tags';
|
|
4
|
+
const edgeFunctionExample = codeBlock `
|
|
5
|
+
import "jsr:@supabase/functions-js/edge-runtime.d.ts";
|
|
6
|
+
|
|
7
|
+
Deno.serve(async (req: Request) => {
|
|
8
|
+
const data = {
|
|
9
|
+
message: "Hello there!"
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
return new Response(JSON.stringify(data), {
|
|
13
|
+
headers: {
|
|
14
|
+
'Content-Type': 'application/json',
|
|
15
|
+
'Connection': 'keep-alive'
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
`;
|
|
20
|
+
export const getSupabaseTools = () => [
|
|
21
|
+
{
|
|
22
|
+
name: "list_edge_functions",
|
|
23
|
+
description: "Lists all Edge Functions currently deployed in a Supabase project.",
|
|
24
|
+
inputSchema: zodToJsonSchema(types.ListEdgeFunctions)
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: "deploy_edge_function",
|
|
28
|
+
description: `
|
|
29
|
+
Deploys an Edge Function to a Supabase project. ALWAYS read from the supabase/functions/ folder to know if the function you are trying to deploy already exists and if it does, read the content of the function. If the function already exists, this tool will update it.
|
|
30
|
+
|
|
31
|
+
Function example:\n\n${edgeFunctionExample}
|
|
32
|
+
|
|
33
|
+
After successful deployment, when using in business code, example: await supabase.functions.invoke('{projectId}_{functionName}') The invocation name should use the combination of project ID and function name (format: projectId_functionName).
|
|
34
|
+
`,
|
|
35
|
+
inputSchema: zodToJsonSchema(types.DeployEdgeFunction)
|
|
36
|
+
}
|
|
37
|
+
];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@catchmexz/fedin-vibe-mcp-server",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.14",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -18,10 +18,11 @@
|
|
|
18
18
|
"start:sse": "node dist/index.js --sse"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
+
"@modelcontextprotocol/sdk": "^1.0.1",
|
|
21
22
|
"ali-oss": "^6.21.0",
|
|
22
23
|
"archiver": "^7.0.1",
|
|
23
24
|
"axios": "^1.7.7",
|
|
24
|
-
"
|
|
25
|
+
"common-tags": "^1.8.2",
|
|
25
26
|
"dotenv": "^16.4.7",
|
|
26
27
|
"express": "^4.18.2",
|
|
27
28
|
"form-data": "^4.0.2",
|
|
@@ -36,8 +37,9 @@
|
|
|
36
37
|
"@types/express": "^5.0.3",
|
|
37
38
|
"@types/fs-extra": "^11.0.4",
|
|
38
39
|
"@types/minimatch": "^5.1.2",
|
|
40
|
+
"@types/common-tags": "^1.8.4",
|
|
39
41
|
"@types/node": "^20.10.5",
|
|
40
42
|
"shx": "^0.3.4",
|
|
41
43
|
"typescript": "^5.8.2"
|
|
42
44
|
}
|
|
43
|
-
}
|
|
45
|
+
}
|