mcp-supabase-selfhosted 1.2.0 → 1.2.1
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/index.js +50 -6
- package/package.json +1 -1
- package/src/index.ts +54 -6
package/dist/index.js
CHANGED
|
@@ -11,14 +11,28 @@ async function main() {
|
|
|
11
11
|
// 2. Inicializar el servidor MCP
|
|
12
12
|
const server = new Server({
|
|
13
13
|
name: 'supabase-selfhosted-mcp',
|
|
14
|
-
version: '1.
|
|
14
|
+
version: '1.2.0',
|
|
15
15
|
}, {
|
|
16
16
|
capabilities: {
|
|
17
17
|
tools: {},
|
|
18
|
-
resources: {
|
|
18
|
+
resources: {
|
|
19
|
+
subscribe: true,
|
|
20
|
+
listChanged: true,
|
|
21
|
+
},
|
|
19
22
|
prompts: {},
|
|
23
|
+
logging: {},
|
|
20
24
|
},
|
|
21
25
|
});
|
|
26
|
+
/**
|
|
27
|
+
* Helper to send log messages to the client.
|
|
28
|
+
*/
|
|
29
|
+
const log = (message, level = 'info') => {
|
|
30
|
+
server.sendLoggingMessage({
|
|
31
|
+
level,
|
|
32
|
+
data: message,
|
|
33
|
+
});
|
|
34
|
+
console.error(`[${level.toUpperCase()}] ${message}`);
|
|
35
|
+
};
|
|
22
36
|
// --- RECURSOS (Resources) ---
|
|
23
37
|
server.setRequestHandler(ListResourcesRequestSchema, async () => {
|
|
24
38
|
return {
|
|
@@ -30,10 +44,19 @@ async function main() {
|
|
|
30
44
|
mimeType: 'application/json',
|
|
31
45
|
},
|
|
32
46
|
],
|
|
47
|
+
resourceTemplates: [
|
|
48
|
+
{
|
|
49
|
+
uriTemplate: 'supabase://database/table/{name}',
|
|
50
|
+
name: 'Table specific schema',
|
|
51
|
+
description: 'Returns the schema for a specific table.',
|
|
52
|
+
mimeType: 'application/json',
|
|
53
|
+
},
|
|
54
|
+
],
|
|
33
55
|
};
|
|
34
56
|
});
|
|
35
57
|
server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
|
|
36
|
-
|
|
58
|
+
const { uri } = request.params;
|
|
59
|
+
if (uri === 'supabase://database/schema') {
|
|
37
60
|
const sql = `
|
|
38
61
|
SELECT table_name, column_name, data_type
|
|
39
62
|
FROM information_schema.columns
|
|
@@ -44,7 +67,28 @@ async function main() {
|
|
|
44
67
|
return {
|
|
45
68
|
contents: [
|
|
46
69
|
{
|
|
47
|
-
uri
|
|
70
|
+
uri,
|
|
71
|
+
mimeType: 'application/json',
|
|
72
|
+
text: JSON.stringify(rows, null, 2),
|
|
73
|
+
},
|
|
74
|
+
],
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
// Handle Resource Templates (Specific Table)
|
|
78
|
+
const tableMatch = uri.match(/^supabase:\/\/database\/table\/(.+)$/);
|
|
79
|
+
if (tableMatch) {
|
|
80
|
+
const tableName = tableMatch[1];
|
|
81
|
+
const sql = `
|
|
82
|
+
SELECT column_name, data_type, is_nullable, column_default
|
|
83
|
+
FROM information_schema.columns
|
|
84
|
+
WHERE table_schema = 'public' AND table_name = $1
|
|
85
|
+
ORDER BY ordinal_position;
|
|
86
|
+
`;
|
|
87
|
+
const rows = await query(sql, [tableName]);
|
|
88
|
+
return {
|
|
89
|
+
contents: [
|
|
90
|
+
{
|
|
91
|
+
uri,
|
|
48
92
|
mimeType: 'application/json',
|
|
49
93
|
text: JSON.stringify(rows, null, 2),
|
|
50
94
|
},
|
|
@@ -124,9 +168,9 @@ async function main() {
|
|
|
124
168
|
// 5. Configurar el transporte stdio (entrada/salida estándar)
|
|
125
169
|
const transport = new StdioServerTransport();
|
|
126
170
|
await server.connect(transport);
|
|
127
|
-
|
|
171
|
+
log('Supabase Self-Hosted MCP Server started successfully.', 'info');
|
|
128
172
|
}
|
|
129
173
|
main().catch((error) => {
|
|
130
|
-
console.error('
|
|
174
|
+
console.error('Fatal error starting MCP server:', error);
|
|
131
175
|
process.exit(1);
|
|
132
176
|
});
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -36,17 +36,32 @@ async function main() {
|
|
|
36
36
|
const server = new Server(
|
|
37
37
|
{
|
|
38
38
|
name: 'supabase-selfhosted-mcp',
|
|
39
|
-
version: '1.
|
|
39
|
+
version: '1.2.0',
|
|
40
40
|
},
|
|
41
41
|
{
|
|
42
42
|
capabilities: {
|
|
43
43
|
tools: {},
|
|
44
|
-
resources: {
|
|
44
|
+
resources: {
|
|
45
|
+
subscribe: true,
|
|
46
|
+
listChanged: true,
|
|
47
|
+
},
|
|
45
48
|
prompts: {},
|
|
49
|
+
logging: {},
|
|
46
50
|
},
|
|
47
51
|
},
|
|
48
52
|
);
|
|
49
53
|
|
|
54
|
+
/**
|
|
55
|
+
* Helper to send log messages to the client.
|
|
56
|
+
*/
|
|
57
|
+
const log = (message: string, level: 'info' | 'error' | 'debug' = 'info') => {
|
|
58
|
+
server.sendLoggingMessage({
|
|
59
|
+
level,
|
|
60
|
+
data: message,
|
|
61
|
+
});
|
|
62
|
+
console.error(`[${level.toUpperCase()}] ${message}`);
|
|
63
|
+
};
|
|
64
|
+
|
|
50
65
|
// --- RECURSOS (Resources) ---
|
|
51
66
|
server.setRequestHandler(ListResourcesRequestSchema, async () => {
|
|
52
67
|
return {
|
|
@@ -58,11 +73,21 @@ async function main() {
|
|
|
58
73
|
mimeType: 'application/json',
|
|
59
74
|
},
|
|
60
75
|
],
|
|
76
|
+
resourceTemplates: [
|
|
77
|
+
{
|
|
78
|
+
uriTemplate: 'supabase://database/table/{name}',
|
|
79
|
+
name: 'Table specific schema',
|
|
80
|
+
description: 'Returns the schema for a specific table.',
|
|
81
|
+
mimeType: 'application/json',
|
|
82
|
+
},
|
|
83
|
+
],
|
|
61
84
|
};
|
|
62
85
|
});
|
|
63
86
|
|
|
64
87
|
server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
|
|
65
|
-
|
|
88
|
+
const { uri } = request.params;
|
|
89
|
+
|
|
90
|
+
if (uri === 'supabase://database/schema') {
|
|
66
91
|
const sql = `
|
|
67
92
|
SELECT table_name, column_name, data_type
|
|
68
93
|
FROM information_schema.columns
|
|
@@ -73,13 +98,36 @@ async function main() {
|
|
|
73
98
|
return {
|
|
74
99
|
contents: [
|
|
75
100
|
{
|
|
76
|
-
uri
|
|
101
|
+
uri,
|
|
77
102
|
mimeType: 'application/json',
|
|
78
103
|
text: JSON.stringify(rows, null, 2),
|
|
79
104
|
},
|
|
80
105
|
],
|
|
81
106
|
};
|
|
82
107
|
}
|
|
108
|
+
|
|
109
|
+
// Handle Resource Templates (Specific Table)
|
|
110
|
+
const tableMatch = uri.match(/^supabase:\/\/database\/table\/(.+)$/);
|
|
111
|
+
if (tableMatch) {
|
|
112
|
+
const tableName = tableMatch[1];
|
|
113
|
+
const sql = `
|
|
114
|
+
SELECT column_name, data_type, is_nullable, column_default
|
|
115
|
+
FROM information_schema.columns
|
|
116
|
+
WHERE table_schema = 'public' AND table_name = $1
|
|
117
|
+
ORDER BY ordinal_position;
|
|
118
|
+
`;
|
|
119
|
+
const rows = await query(sql, [tableName]);
|
|
120
|
+
return {
|
|
121
|
+
contents: [
|
|
122
|
+
{
|
|
123
|
+
uri,
|
|
124
|
+
mimeType: 'application/json',
|
|
125
|
+
text: JSON.stringify(rows, null, 2),
|
|
126
|
+
},
|
|
127
|
+
],
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
|
|
83
131
|
throw new Error('Resource not found');
|
|
84
132
|
});
|
|
85
133
|
|
|
@@ -160,10 +208,10 @@ async function main() {
|
|
|
160
208
|
const transport = new StdioServerTransport();
|
|
161
209
|
await server.connect(transport);
|
|
162
210
|
|
|
163
|
-
|
|
211
|
+
log('Supabase Self-Hosted MCP Server started successfully.', 'info');
|
|
164
212
|
}
|
|
165
213
|
|
|
166
214
|
main().catch((error) => {
|
|
167
|
-
console.error('
|
|
215
|
+
console.error('Fatal error starting MCP server:', error);
|
|
168
216
|
process.exit(1);
|
|
169
217
|
});
|