Skip to content

Commit 70695b0

Browse files
authored
Merge pull request #5 from zenstackhq/dev
dev to main
2 parents 2d00497 + dc2e498 commit 70695b0

2 files changed

Lines changed: 15 additions & 11 deletions

File tree

‎package.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@zenstackhq/studio-mcp-remote",
3-
"version": "1.1.0",
3+
"version": "1.2.0",
44
"description": "Local stdio MCP server bridging client calls and ZenStack local database proxy",
55
"type": "module",
66
"main": "./dist/index.js",
@@ -36,4 +36,4 @@
3636
"engines": {
3737
"node": ">=18.0.0"
3838
}
39-
}
39+
}

‎src/proxy.ts‎

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
import SuperJSON from 'superjson'
22
import type { McpOperation } from './types.js'
33

4-
const READ_OPERATIONS = new Set(['findMany', 'findFirst', 'findUnique', 'count'])
4+
const READ_OPERATIONS = new Set([
5+
'findMany',
6+
'findUnique',
7+
'findFirst',
8+
'count',
9+
'aggregate',
10+
'groupBy',
11+
])
12+
const DELETE_OPERATIONS = new Set(['delete', 'deleteMany'])
13+
const UPDATE_OPERATIONS = new Set(['update', 'updateMany', 'updateManyAndReturn'])
514

615
export async function executeProxyOperation(
716
proxyUrl: string,
@@ -10,7 +19,8 @@ export async function executeProxyOperation(
1019
): Promise<unknown> {
1120
const { json, meta } = SuperJSON.serialize(operation.args ?? {})
1221
const isRead = READ_OPERATIONS.has(operation.operation)
13-
const isDelete = operation.operation === 'deleteMany'
22+
const isDelete = DELETE_OPERATIONS.has(operation.operation)
23+
const isUpdate = UPDATE_OPERATIONS.has(operation.operation)
1424

1525
const query = `q=${encodeURIComponent(JSON.stringify(json))}${
1626
meta && Object.keys(meta).length
@@ -30,13 +40,7 @@ export async function executeProxyOperation(
3040
const authHeader = authorization.startsWith('Bearer ') ? authorization : `Bearer ${authorization}`
3141

3242
const response = await fetch(url, {
33-
method: isRead
34-
? 'GET'
35-
: isDelete
36-
? 'DELETE'
37-
: operation.operation === 'update'
38-
? 'PUT'
39-
: 'POST',
43+
method: isRead ? 'GET' : isDelete ? 'DELETE' : isUpdate ? 'PUT' : 'POST',
4044
headers: {
4145
Authorization: authHeader,
4246
'Content-Type': 'application/json',

0 commit comments

Comments
 (0)