Skip to content

Commit f3a08bc

Browse files
Copilothotlong
andauthored
refactor: extract tool classification sets to module-level constants
Moves READ_ONLY_TOOLS and DESTRUCTIVE_TOOLS from inline arrays to module-level Set constants for better maintainability. Agent-Logs-Url: https://github.com/objectstack-ai/framework/sessions/5eb90a65-846f-4f24-947f-1c0e7ea5090e Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent a31c298 commit f3a08bc

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

packages/plugins/plugin-mcp-server/src/mcp-server-runtime.ts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,25 @@ interface ObjectDef {
3333
enable?: Record<string, boolean>;
3434
}
3535

36+
/**
37+
* Names of tools that are read-only (no side effects).
38+
* Kept as a module-level constant for easy extension.
39+
*/
40+
const READ_ONLY_TOOLS = new Set([
41+
'list_objects',
42+
'describe_object',
43+
'query_records',
44+
'get_record',
45+
'aggregate_data',
46+
]);
47+
48+
/**
49+
* Names of tools that perform destructive mutations.
50+
*/
51+
const DESTRUCTIVE_TOOLS = new Set([
52+
'delete_field',
53+
]);
54+
3655
/**
3756
* MCPServerRuntime — Bridges ObjectStack kernel services to the Model Context Protocol.
3857
*
@@ -191,14 +210,14 @@ export class MCPServerRuntime {
191210
* Check if a tool is read-only (data query tools).
192211
*/
193212
private isReadOnlyTool(name: string): boolean {
194-
return ['list_objects', 'describe_object', 'query_records', 'get_record', 'aggregate_data'].includes(name);
213+
return READ_ONLY_TOOLS.has(name);
195214
}
196215

197216
/**
198217
* Check if a tool performs destructive operations.
199218
*/
200219
private isDestructiveTool(name: string): boolean {
201-
return ['delete_field'].includes(name);
220+
return DESTRUCTIVE_TOOLS.has(name);
202221
}
203222

204223
// ── Resource Bridge ────────────────────────────────────────────

0 commit comments

Comments
 (0)