veryfront 0.1.141 → 0.1.142

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.
Files changed (66) hide show
  1. package/esm/cli/mcp/jsonrpc.d.ts +33 -1
  2. package/esm/cli/mcp/jsonrpc.d.ts.map +1 -1
  3. package/esm/cli/mcp/jsonrpc.js +63 -4
  4. package/esm/cli/mcp/remote-file-tools.d.ts.map +1 -1
  5. package/esm/cli/mcp/remote-file-tools.js +39 -0
  6. package/esm/cli/mcp/server.d.ts.map +1 -1
  7. package/esm/cli/mcp/server.js +57 -34
  8. package/esm/cli/mcp/standalone.d.ts.map +1 -1
  9. package/esm/cli/mcp/standalone.js +24 -11
  10. package/esm/cli/mcp/tools/catalog-tools.d.ts.map +1 -1
  11. package/esm/cli/mcp/tools/catalog-tools.js +15 -5
  12. package/esm/cli/mcp/tools/cicd-tools.d.ts.map +1 -1
  13. package/esm/cli/mcp/tools/cicd-tools.js +8 -0
  14. package/esm/cli/mcp/tools/dev-tools.d.ts.map +1 -1
  15. package/esm/cli/mcp/tools/dev-tools.js +32 -10
  16. package/esm/cli/mcp/tools/introspection-tools.d.ts.map +1 -1
  17. package/esm/cli/mcp/tools/introspection-tools.js +6 -2
  18. package/esm/cli/mcp/tools/project-tools.d.ts.map +1 -1
  19. package/esm/cli/mcp/tools/project-tools.js +12 -4
  20. package/esm/cli/mcp/tools/scaffold-tools.d.ts.map +1 -1
  21. package/esm/cli/mcp/tools/scaffold-tools.js +6 -2
  22. package/esm/cli/mcp/tools/skill-tools.d.ts.map +1 -1
  23. package/esm/cli/mcp/tools/skill-tools.js +6 -2
  24. package/esm/cli/mcp/tools.d.ts.map +1 -1
  25. package/esm/cli/mcp/tools.js +36 -16
  26. package/esm/deno.js +1 -1
  27. package/esm/src/agent/runtime/index.js +1 -1
  28. package/esm/src/agent/runtime/tool-helpers.d.ts.map +1 -1
  29. package/esm/src/agent/runtime/tool-helpers.js +59 -30
  30. package/esm/src/agent/schemas/agent.schema.d.ts +4 -4
  31. package/esm/src/channels/invoke.d.ts +4 -4
  32. package/esm/src/issues/mcp.d.ts.map +1 -1
  33. package/esm/src/issues/mcp.js +39 -10
  34. package/esm/src/mcp/index.d.ts +1 -1
  35. package/esm/src/mcp/index.d.ts.map +1 -1
  36. package/esm/src/mcp/server.d.ts.map +1 -1
  37. package/esm/src/mcp/server.js +85 -25
  38. package/esm/src/mcp/types.d.ts +22 -0
  39. package/esm/src/mcp/types.d.ts.map +1 -1
  40. package/esm/src/tool/types.d.ts +5 -0
  41. package/esm/src/tool/types.d.ts.map +1 -1
  42. package/esm/src/utils/version-constant.d.ts +1 -1
  43. package/esm/src/utils/version-constant.js +1 -1
  44. package/esm/src/workflow/schemas/workflow.schema.d.ts +6 -6
  45. package/package.json +1 -1
  46. package/src/cli/mcp/jsonrpc.ts +72 -4
  47. package/src/cli/mcp/remote-file-tools.ts +39 -0
  48. package/src/cli/mcp/server.ts +66 -33
  49. package/src/cli/mcp/standalone.ts +28 -10
  50. package/src/cli/mcp/tools/catalog-tools.ts +15 -5
  51. package/src/cli/mcp/tools/cicd-tools.ts +8 -0
  52. package/src/cli/mcp/tools/dev-tools.ts +34 -10
  53. package/src/cli/mcp/tools/introspection-tools.ts +7 -2
  54. package/src/cli/mcp/tools/project-tools.ts +12 -4
  55. package/src/cli/mcp/tools/scaffold-tools.ts +6 -2
  56. package/src/cli/mcp/tools/skill-tools.ts +6 -2
  57. package/src/cli/mcp/tools.ts +52 -16
  58. package/src/deno.js +1 -1
  59. package/src/src/agent/runtime/index.ts +1 -1
  60. package/src/src/agent/runtime/tool-helpers.ts +86 -36
  61. package/src/src/issues/mcp.ts +43 -10
  62. package/src/src/mcp/index.ts +7 -1
  63. package/src/src/mcp/server.ts +92 -31
  64. package/src/src/mcp/types.ts +24 -0
  65. package/src/src/tool/types.ts +7 -0
  66. package/src/src/utils/version-constant.ts +1 -1
@@ -35,18 +35,24 @@ export function setServerStartTime(time: number): void {
35
35
 
36
36
  const getErrorsInput = z.object({
37
37
  type: z.enum(["compile", "runtime", "bundle", "hmr", "module"]).optional().describe(
38
- "Filter by error type",
38
+ "Filter by error type. Example: 'compile'. Omit to return all types.",
39
+ ),
40
+ file: z.string().optional().describe(
41
+ "Filter by file path. Example: 'app/page.tsx'. Omit to return errors from all files.",
42
+ ),
43
+ limit: z.number().optional().default(50).describe(
44
+ "Maximum number of errors to return. Defaults to 50.",
39
45
  ),
40
- file: z.string().optional().describe("Filter by file path"),
41
- limit: z.number().optional().default(50).describe("Maximum number of errors to return"),
42
46
  });
43
47
 
44
48
  type GetErrorsInput = z.infer<typeof getErrorsInput>;
45
49
 
46
50
  export const vfGetErrors: MCPTool<GetErrorsInput, DevError[]> = {
47
51
  name: "vf_get_errors",
52
+ title: "Get Errors",
53
+ annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: false },
48
54
  description:
49
- "Get compilation, runtime, and build errors from the dev server. Use this to debug issues with your code.",
55
+ "Use this when you need to check for compilation, runtime, bundle, HMR, or module errors in the dev server. Returns error details including file path, line number, and message. Do not use for server logs — use vf_get_logs instead.",
50
56
  inputSchema: getErrorsInput,
51
57
  execute: async (input) => {
52
58
  const errors = getErrorCollector().getAll({
@@ -60,21 +66,31 @@ export const vfGetErrors: MCPTool<GetErrorsInput, DevError[]> = {
60
66
  };
61
67
 
62
68
  const getLogsInput = z.object({
63
- level: z.enum(["debug", "info", "warn", "error"]).optional().describe("Filter by log level"),
69
+ level: z.enum(["debug", "info", "warn", "error"]).optional().describe(
70
+ "Filter by log level. Example: 'error'. Omit to return all levels.",
71
+ ),
64
72
  source: z.string().optional().describe(
65
- "Filter by log source (e.g., 'server', 'hmr', 'transform')",
73
+ "Filter by log source. Example: 'server', 'hmr', 'transform'. Omit to return all sources.",
74
+ ),
75
+ pattern: z.string().optional().describe(
76
+ "Filter by pattern (case-insensitive substring match). Example: 'timeout'.",
77
+ ),
78
+ limit: z.number().optional().default(100).describe(
79
+ "Maximum number of log entries to return. Defaults to 100.",
80
+ ),
81
+ since: z.number().optional().describe(
82
+ "Only return logs after this Unix timestamp in milliseconds.",
66
83
  ),
67
- pattern: z.string().optional().describe("Filter by pattern (case-insensitive substring match)"),
68
- limit: z.number().optional().default(100).describe("Maximum number of log entries to return"),
69
- since: z.number().optional().describe("Only return logs after this timestamp"),
70
84
  });
71
85
 
72
86
  type GetLogsInput = z.infer<typeof getLogsInput>;
73
87
 
74
88
  export const vfGetLogs: MCPTool<GetLogsInput, LogEntry[]> = {
75
89
  name: "vf_get_logs",
90
+ title: "Get Logs",
91
+ annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: false },
76
92
  description:
77
- "Get recent server logs. Use this to understand what the server is doing and debug runtime issues.",
93
+ "Use this when you need to inspect server logs to understand runtime behavior or debug request handling. Returns log entries with timestamp, level, source, and message. Do not use for build/compile errors — use vf_get_errors instead.",
78
94
  inputSchema: getLogsInput,
79
95
  execute: async (input) => {
80
96
  return getLogBuffer().query({
@@ -89,7 +105,7 @@ export const vfGetLogs: MCPTool<GetLogsInput, LogEntry[]> = {
89
105
 
90
106
  const clearCacheInput = z.object({
91
107
  type: z.enum(["all", "modules", "mdx"]).optional().default("all").describe(
92
- "Type of cache to clear",
108
+ "Type of cache to clear. Example: 'modules'. Defaults to 'all'.",
93
109
  ),
94
110
  });
95
111
 
@@ -102,8 +118,15 @@ interface ClearCacheOutput {
102
118
 
103
119
  export const vfClearCache: MCPTool<ClearCacheInput, ClearCacheOutput> = {
104
120
  name: "vf_clear_cache",
121
+ title: "Clear Cache",
122
+ annotations: {
123
+ readOnlyHint: false,
124
+ destructiveHint: true,
125
+ idempotentHint: true,
126
+ openWorldHint: false,
127
+ },
105
128
  description:
106
- "Clear module and build caches. Use this when changes aren't being reflected or to force a rebuild.",
129
+ "Use this when the dev server shows stale modules or MDX content. Returns the list of cleared cache directories. Do not use to fix code errors — those require code changes.",
107
130
  inputSchema: clearCacheInput,
108
131
  execute: async (input) => {
109
132
  const fs = createFileSystem();
@@ -143,7 +166,10 @@ export function createVfGetStatus(
143
166
  ): MCPTool<GetStatusInput, ServerStatus> {
144
167
  return {
145
168
  name: "vf_get_status",
146
- description: "Get the current status of the dev server including error counts and uptime.",
169
+ title: "Server Status",
170
+ annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: false },
171
+ description:
172
+ "Use this when you need a quick summary of the dev server's uptime, error counts, and warning counts. Note: always reports running=true when the MCP server is reachable. Do not use for detailed error info — use vf_get_errors instead.",
147
173
  inputSchema: getStatusInput,
148
174
  execute: async () => {
149
175
  const errors = getErrorCollector();
@@ -167,9 +193,11 @@ export function createVfGetStatus(
167
193
  export const vfGetStatus = createVfGetStatus();
168
194
 
169
195
  const clearErrorsInput = z.object({
170
- file: z.string().optional().describe("Clear errors for a specific file only"),
196
+ file: z.string().optional().describe(
197
+ "Clear errors for a specific file only. Example: 'app/page.tsx'. Omit to clear all files.",
198
+ ),
171
199
  type: z.enum(["compile", "runtime", "bundle", "hmr", "module"]).optional().describe(
172
- "Clear errors of a specific type only",
200
+ "Clear errors of a specific type only. Example: 'compile'. Omit to clear all types.",
173
201
  ),
174
202
  });
175
203
 
@@ -181,7 +209,15 @@ interface ClearErrorsOutput {
181
209
 
182
210
  export const vfClearErrors: MCPTool<ClearErrorsInput, ClearErrorsOutput> = {
183
211
  name: "vf_clear_errors",
184
- description: "Clear errors from the error collector. Useful after fixing issues.",
212
+ title: "Clear Errors",
213
+ annotations: {
214
+ readOnlyHint: false,
215
+ destructiveHint: true,
216
+ idempotentHint: true,
217
+ openWorldHint: false,
218
+ },
219
+ description:
220
+ "Use this when you need to clear accumulated errors from the error collector, optionally filtering by file or type. Returns the number of cleared errors. Do not use for viewing errors — use vf_get_errors instead.",
185
221
  inputSchema: clearErrorsInput,
186
222
  execute: async (input) => {
187
223
  const collector = getErrorCollector();
package/src/deno.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export default {
2
2
  "name": "veryfront",
3
- "version": "0.1.141",
3
+ "version": "0.1.142",
4
4
  "license": "Apache-2.0",
5
5
  "nodeModulesDir": "auto",
6
6
  "exclude": [
@@ -406,7 +406,7 @@ export class AgentRuntime {
406
406
  logger.error("Agent stream error", { error });
407
407
  sendSSE(controller, encoder, {
408
408
  type: "error",
409
- error: "An internal error occurred",
409
+ error: error instanceof Error ? error.message : String(error),
410
410
  });
411
411
  closeSSEStream(controller);
412
412
  } finally {
@@ -11,6 +11,7 @@ import { executeTool, toolRegistry } from "../../tool/index.js";
11
11
  import { toolToProviderDefinition } from "../../tool/registry.js";
12
12
  import { SKILL_TOOL_IDS } from "../../skill/types.js";
13
13
  import { serverLogger } from "../../utils/index.js";
14
+ import { createError, toError } from "../../errors/veryfront-error.js";
14
15
  import {
15
16
  executeRemoteIntegrationTool,
16
17
  isRemoteIntegrationTool,
@@ -71,6 +72,52 @@ export function isDynamicTool(name: string): boolean {
71
72
  // deno-lint-ignore no-explicit-any -- generic erasure: accepts Tool with any input/output types
72
73
  export type ToolConfigEntry = Tool<any, any> | boolean;
73
74
 
75
+ function formatAvailableToolNames(names: Iterable<string>): string {
76
+ const sorted = [...new Set(names)].sort();
77
+ return sorted.length > 0 ? sorted.join(", ") : "(none)";
78
+ }
79
+
80
+ function throwUnknownConfiguredToolsError(
81
+ unknownToolNames: string[],
82
+ availableLocalToolNames: Iterable<string>,
83
+ availableRemoteToolNames: Iterable<string>,
84
+ ): never {
85
+ const unknownList = unknownToolNames.sort().join(", ");
86
+ const availableNames = formatAvailableToolNames([
87
+ ...availableLocalToolNames,
88
+ ...availableRemoteToolNames,
89
+ ]);
90
+
91
+ throw toError(
92
+ createError({
93
+ type: "agent",
94
+ message:
95
+ `Unknown tool reference${unknownToolNames.length === 1 ? "" : "s"}: ${unknownList}. ` +
96
+ `Tool names must exactly match tool({ id: "..." }). Available tools: ${availableNames}`,
97
+ }),
98
+ );
99
+ }
100
+
101
+ async function getRemoteToolDefinitions(options?: {
102
+ includeIntegrationTools?: boolean;
103
+ allowedRemoteToolNames?: string[];
104
+ }): Promise<ToolDefinition[]> {
105
+ if (options?.includeIntegrationTools === false) {
106
+ return [];
107
+ }
108
+
109
+ try {
110
+ const { getRemoteIntegrationToolDefinitions } = await import(
111
+ "../../integrations/remote-tools.js"
112
+ );
113
+ return (await getRemoteIntegrationToolDefinitions()).filter((def) =>
114
+ !options?.allowedRemoteToolNames || options.allowedRemoteToolNames.includes(def.name)
115
+ );
116
+ } catch {
117
+ return [];
118
+ }
119
+ }
120
+
74
121
  export function resolveConfiguredTool(
75
122
  toolsConfig: true | Record<string, ToolConfigEntry> | undefined,
76
123
  toolName: string,
@@ -179,32 +226,35 @@ export async function getAvailableTools(
179
226
  });
180
227
 
181
228
  // Append remote integration tools (per-request, project-scoped)
182
- if (options?.includeIntegrationTools !== false) {
183
- try {
184
- const { getRemoteIntegrationToolDefinitions } = await import(
185
- "../../integrations/remote-tools.js"
186
- );
187
- const remoteDefs = (await getRemoteIntegrationToolDefinitions()).filter((def) =>
188
- !options?.allowedRemoteToolNames || options.allowedRemoteToolNames.includes(def.name)
189
- );
190
- for (const def of remoteDefs) {
191
- logToolDefinition(def.name, def);
192
- }
193
- tools.push(...remoteDefs);
194
- } catch {
195
- // Integration tools unavailable — non-fatal
196
- }
229
+ const remoteDefs = await getRemoteToolDefinitions(options);
230
+ for (const def of remoteDefs) {
231
+ logToolDefinition(def.name, def);
197
232
  }
233
+ tools.push(...remoteDefs);
198
234
 
199
235
  return tools;
200
236
  }
201
237
 
202
238
  const tools: ToolDefinition[] = [];
239
+ const remoteDefs = await getRemoteToolDefinitions(options);
240
+ const remoteToolNames = new Set(remoteDefs.map((def) => def.name));
241
+ const explicitlyRequestedRemoteToolNames = new Set<string>();
242
+ const unresolvedConfiguredToolNames: string[] = [];
203
243
 
204
244
  for (const [name, entry] of Object.entries(toolsConfig)) {
205
245
  if (entry === true) {
206
246
  const tool = toolRegistry.get(name);
207
- if (tool) addToolDefinition(tools, name, tool);
247
+ if (tool) {
248
+ addToolDefinition(tools, name, tool);
249
+ continue;
250
+ }
251
+
252
+ if (remoteToolNames.has(name)) {
253
+ explicitlyRequestedRemoteToolNames.add(name);
254
+ continue;
255
+ }
256
+
257
+ unresolvedConfiguredToolNames.push(name);
208
258
  continue;
209
259
  }
210
260
 
@@ -213,28 +263,28 @@ export async function getAvailableTools(
213
263
  }
214
264
  }
215
265
 
216
- // Also append remote integration tools for explicit-object configs.
217
- // The internal streaming path converts `tools: true` to an explicit object
218
- // from the local registry, so remote tools would be missed without this.
219
- if (options?.includeIntegrationTools !== false) {
220
- try {
221
- const { getRemoteIntegrationToolDefinitions } = await import(
222
- "../../integrations/remote-tools.js"
223
- );
224
- const remoteDefs = (await getRemoteIntegrationToolDefinitions()).filter((def) =>
225
- !options?.allowedRemoteToolNames || options.allowedRemoteToolNames.includes(def.name)
226
- );
227
- for (const def of remoteDefs) {
228
- // Skip if already present (e.g., explicitly configured by name)
229
- if (!tools.some((t) => t.name === def.name)) {
230
- logToolDefinition(def.name, def);
231
- tools.push(def);
232
- }
233
- }
234
- } catch {
235
- // Integration tools unavailable — non-fatal
266
+ // Explicit-object configs should only expose remote definitions that were
267
+ // explicitly requested, except for the internal runtime path that expands
268
+ // `tools: true` into an explicit local-tool map and passes the remote allowlist.
269
+ const remoteDefsToAppend = explicitlyRequestedRemoteToolNames.size > 0
270
+ ? remoteDefs.filter((def) => explicitlyRequestedRemoteToolNames.has(def.name))
271
+ : remoteDefs.filter((def) => options?.allowedRemoteToolNames?.includes(def.name));
272
+
273
+ for (const def of remoteDefsToAppend) {
274
+ // Skip if already present (e.g., explicitly configured by name)
275
+ if (!tools.some((t) => t.name === def.name)) {
276
+ logToolDefinition(def.name, def);
277
+ tools.push(def);
236
278
  }
237
279
  }
238
280
 
281
+ if (unresolvedConfiguredToolNames.length > 0) {
282
+ throwUnknownConfiguredToolsError(
283
+ unresolvedConfiguredToolNames,
284
+ toolRegistry.getAll().keys(),
285
+ remoteToolNames,
286
+ );
287
+ }
288
+
239
289
  return tools;
240
290
  }
@@ -53,8 +53,11 @@ type IssuesCreateInput = z.infer<typeof issuesCreateInput>;
53
53
 
54
54
  const issuesCreate: MCPTool<IssuesCreateInput, Issue> = {
55
55
  name: "issues_create",
56
- description: "Create a new issue, task, or plan as a markdown file. " +
57
- "Use prefix 'TASK' for small work items, 'PLAN' for proposals/RFCs, 'ISSUE' for bugs/features.",
56
+ title: "Create Issue",
57
+ annotations: { readOnlyHint: false, destructiveHint: false, openWorldHint: false },
58
+ description: "Use this when you need to create a new issue, task, or plan as a markdown file. " +
59
+ "Use prefix 'TASK' for small work items, 'PLAN' for proposals/RFCs, 'ISSUE' for bugs/features. " +
60
+ "Returns the created issue. Do not use for updating — use issues_update instead.",
58
61
  inputSchema: issuesCreateInput,
59
62
  execute: async (input) => {
60
63
  const manager = getManager(input.projectDir);
@@ -81,7 +84,10 @@ type IssuesGetInput = z.infer<typeof issuesGetInput>;
81
84
 
82
85
  const issuesGet: MCPTool<IssuesGetInput, Issue | null> = {
83
86
  name: "issues_get",
84
- description: "Get a specific issue by ID. Returns null if not found.",
87
+ title: "Get Issue",
88
+ annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: false },
89
+ description:
90
+ "Use this when you need to retrieve a specific issue by its ID. Returns the issue or null if not found. Do not use for listing — use issues_list instead.",
85
91
  inputSchema: issuesGetInput,
86
92
  execute: async (input) => {
87
93
  const manager = getManager(input.projectDir);
@@ -107,8 +113,16 @@ type IssuesUpdateInput = z.infer<typeof issuesUpdateInput>;
107
113
 
108
114
  const issuesUpdate: MCPTool<IssuesUpdateInput, Issue | null> = {
109
115
  name: "issues_update",
110
- description: "Update an existing issue. Only provided fields are updated. " +
111
- "Returns the updated issue or null if not found.",
116
+ title: "Update Issue",
117
+ annotations: {
118
+ readOnlyHint: false,
119
+ destructiveHint: false,
120
+ idempotentHint: true,
121
+ openWorldHint: false,
122
+ },
123
+ description:
124
+ "Use this when you need to modify an existing issue. Only provided fields are updated. " +
125
+ "Returns the updated issue or null if not found. Do not use to close — use issues_close instead.",
112
126
  inputSchema: issuesUpdateInput,
113
127
  execute: async (input) => {
114
128
  const manager = getManager(input.projectDir);
@@ -153,8 +167,10 @@ interface IssuesListOutput {
153
167
 
154
168
  const issuesList: MCPTool<IssuesListInput, IssuesListOutput> = {
155
169
  name: "issues_list",
156
- description: "List issues with filtering and sorting. " +
157
- "Returns matching issues and total count.",
170
+ title: "List Issues",
171
+ annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: false },
172
+ description: "Use this when you need to find issues matching criteria. " +
173
+ "Returns matching issues and total count. Do not use to get a single known issue — use issues_get instead.",
158
174
  inputSchema: issuesListInput,
159
175
  execute: async (input) => {
160
176
  const manager = getManager(input.projectDir);
@@ -183,7 +199,15 @@ type IssuesCloseInput = z.infer<typeof issuesCloseInput>;
183
199
 
184
200
  const issuesClose: MCPTool<IssuesCloseInput, Issue | null> = {
185
201
  name: "issues_close",
186
- description: "Close an issue. Returns the updated issue or null if not found.",
202
+ title: "Close Issue",
203
+ annotations: {
204
+ readOnlyHint: false,
205
+ destructiveHint: false,
206
+ idempotentHint: true,
207
+ openWorldHint: false,
208
+ },
209
+ description:
210
+ "Use this when you need to close an issue. Returns the updated issue or null if not found. Do not use to delete — use issues_delete instead.",
187
211
  inputSchema: issuesCloseInput,
188
212
  execute: async (input) => {
189
213
  const manager = getManager(input.projectDir);
@@ -207,8 +231,17 @@ interface IssuesDeleteOutput {
207
231
 
208
232
  const issuesDelete: MCPTool<IssuesDeleteInput, IssuesDeleteOutput> = {
209
233
  name: "issues_delete",
210
- description: "Permanently delete an issue file. " +
211
- "Use with caution - this cannot be undone.",
234
+ title: "Delete Issue",
235
+ annotations: {
236
+ readOnlyHint: false,
237
+ destructiveHint: true,
238
+ idempotentHint: true,
239
+ openWorldHint: false,
240
+ },
241
+ description:
242
+ "Use this when you need to permanently delete an issue. Returns {deleted: true/false}. " +
243
+ "WARNING: this is irreversible and cannot be undone. Prefer issues_close unless permanent deletion is explicitly requested. " +
244
+ "Do not use to close — use issues_close instead.",
212
245
  inputSchema: issuesDeleteInput,
213
246
  execute: async (input) => {
214
247
  const manager = getManager(input.projectDir);
@@ -24,7 +24,13 @@
24
24
  import "../../_dnt.polyfills.js";
25
25
 
26
26
 
27
- export type { MCPServerConfig, MCPStats, MCPTool } from "./types.js";
27
+ export type {
28
+ MCPServerConfig,
29
+ MCPStats,
30
+ MCPTool,
31
+ ToolAnnotations,
32
+ ToolListEntry,
33
+ } from "./types.js";
28
34
 
29
35
  export {
30
36
  clearMCPRegistry,
@@ -5,7 +5,7 @@ import type { ToolExecutionContext } from "../tool/index.js";
5
5
  import { zodToJsonSchema } from "../tool/schema/index.js";
6
6
  import { resourceRegistry } from "../resource/index.js";
7
7
  import { promptRegistry } from "../prompt/index.js";
8
- import type { MCPServerConfig } from "./types.js";
8
+ import type { MCPServerConfig, ToolListEntry } from "./types.js";
9
9
  import { createError, toError } from "../errors/veryfront-error.js";
10
10
  import { withSpan } from "../observability/tracing/otlp-setup.js";
11
11
  import { VERSION } from "../utils/version.js";
@@ -24,6 +24,30 @@ const PROJECT_ID_PATTERN = /^[a-zA-Z0-9._-]+$/;
24
24
 
25
25
  type JSONRPCParams = Record<string, unknown> | unknown[];
26
26
 
27
+ class JsonRpcError extends Error {
28
+ readonly code: number;
29
+ constructor(code: number, message: string) {
30
+ super(message);
31
+ this.code = code;
32
+ }
33
+ }
34
+
35
+ function errorCode(error: unknown): number {
36
+ if (typeof error === "object" && error !== null && "code" in error) {
37
+ const code = (error as { code: unknown }).code;
38
+ if (typeof code === "number") return code;
39
+ }
40
+ return -32603;
41
+ }
42
+
43
+ function errorMessage(error: unknown): string {
44
+ if (error instanceof Error) return error.message;
45
+ if (typeof error === "object" && error !== null && "message" in error) {
46
+ return String((error as { message: unknown }).message);
47
+ }
48
+ return String(error);
49
+ }
50
+
27
51
  function toParamsRecord(params: JSONRPCParams | undefined): Record<string, unknown> {
28
52
  if (!params || Array.isArray(params)) return {};
29
53
  return params;
@@ -82,6 +106,8 @@ export interface IntegrationLoaderConfig {
82
106
  apiToken?: string;
83
107
  }
84
108
 
109
+ const MCP_SUPPORTED_VERSIONS = ["2025-11-25", "2024-11-05"];
110
+
85
111
  export class MCPServer {
86
112
  private config: MCPServerConfig;
87
113
  private integrationLoader?: IntegrationLoaderConfig;
@@ -118,10 +144,7 @@ export class MCPServer {
118
144
  return {
119
145
  jsonrpc: "2.0",
120
146
  id: request.id,
121
- error: {
122
- code: -32603,
123
- message: error instanceof Error ? error.message : String(error),
124
- },
147
+ error: { code: errorCode(error), message: errorMessage(error) },
125
148
  };
126
149
  }
127
150
  },
@@ -149,6 +172,8 @@ export class MCPServer {
149
172
  return this.getPrompt(params);
150
173
  case "initialize":
151
174
  return this.initialize(params);
175
+ case "notifications/initialized":
176
+ return Promise.resolve({});
152
177
  default:
153
178
  throw toError(
154
179
  createError({
@@ -159,19 +184,33 @@ export class MCPServer {
159
184
  }
160
185
  }
161
186
 
162
- private initialize(_params: JSONRPCParams | undefined): Promise<Record<string, unknown>> {
187
+ private initialize(params: JSONRPCParams | undefined): Promise<Record<string, unknown>> {
188
+ const p = toParamsRecord(params);
189
+ const requested = typeof p.protocolVersion === "string" ? p.protocolVersion : undefined;
190
+ const negotiated = requested && MCP_SUPPORTED_VERSIONS.includes(requested)
191
+ ? requested
192
+ : MCP_SUPPORTED_VERSIONS[0];
193
+
163
194
  return Promise.resolve({
164
- protocolVersion: "2024-11-05",
165
- serverInfo: { name: "veryfront-mcp", version: VERSION },
195
+ protocolVersion: negotiated,
196
+ serverInfo: {
197
+ name: "veryfront-mcp",
198
+ title: "Veryfront MCP Server",
199
+ version: VERSION,
200
+ description:
201
+ "Veryfront development server tools for real-time errors, route preview, HMR control, and scaffolding",
202
+ },
166
203
  capabilities: {
167
- tools: {},
168
- resources: { subscribe: true },
169
- prompts: {},
204
+ tools: { listChanged: true },
205
+ resources: { subscribe: true, listChanged: true },
206
+ prompts: { listChanged: true },
170
207
  },
208
+ instructions:
209
+ "Veryfront MCP server provides development tools. Use vf_get_errors to check for code errors, vf_get_logs for server logs, vf_scaffold for code generation, and vf_get_project_context for project structure.",
171
210
  });
172
211
  }
173
212
 
174
- private async listTools(): Promise<{ tools: Array<Record<string, unknown>> }> {
213
+ private async listTools(): Promise<{ tools: ToolListEntry[] }> {
175
214
  // Sync integration config to API on first tools/list call
176
215
  if (this.integrationLoader && !this.integrationsLoaded) {
177
216
  try {
@@ -182,16 +221,19 @@ export class MCPServer {
182
221
  }
183
222
 
184
223
  const registry = getMCPRegistry();
185
- const tools: Array<Record<string, unknown>> = [];
224
+ const tools: ToolListEntry[] = [];
186
225
 
187
226
  for (const [id, tool] of registry.tools.entries()) {
188
227
  if (tool.mcp?.enabled === false) continue;
189
228
 
190
- tools.push({
229
+ const entry: ToolListEntry = {
191
230
  name: id,
192
231
  description: tool.description,
193
232
  inputSchema: tool.inputSchemaJson ?? zodToJsonSchema(tool.inputSchema),
194
- });
233
+ };
234
+ if (tool.mcp?.title) entry.title = tool.mcp.title;
235
+ if (tool.mcp?.annotations) entry.annotations = tool.mcp.annotations;
236
+ tools.push(entry);
195
237
  }
196
238
 
197
239
  return { tools };
@@ -204,29 +246,42 @@ export class MCPServer {
204
246
  const { name, arguments: args } = toParamsRecord(params);
205
247
 
206
248
  if (!name) {
207
- throw toError(
208
- createError({
209
- type: "agent",
210
- message: "Tool name is required",
211
- }),
212
- );
249
+ throw toError(createError({ type: "agent", message: "Tool name is required" }));
213
250
  }
214
251
 
215
252
  const toolName = String(name);
216
253
 
254
+ const registry = getMCPRegistry();
255
+ const tool = registry.tools.get(toolName);
256
+ if (!tool) {
257
+ throw new JsonRpcError(-32602, `Unknown tool: ${toolName}`);
258
+ }
259
+
260
+ if (tool.inputSchema && typeof tool.inputSchema.parse === "function") {
261
+ try {
262
+ tool.inputSchema.parse(args ?? {});
263
+ } catch (error) {
264
+ const message = error instanceof Error ? error.message : String(error);
265
+ throw new JsonRpcError(-32602, `Invalid arguments for tool ${toolName}: ${message}`);
266
+ }
267
+ }
268
+
217
269
  return withSpan(
218
270
  "mcp.callTool",
219
271
  async () => {
220
- const result = await executeTool(toolName, args, context);
221
-
222
- return {
223
- content: [
224
- {
225
- type: "text",
226
- text: JSON.stringify(result, null, 2),
227
- },
228
- ],
229
- };
272
+ try {
273
+ const result = await executeTool(toolName, args, context);
274
+ return {
275
+ content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
276
+ isError: false,
277
+ };
278
+ } catch (error) {
279
+ const message = error instanceof Error ? error.message : String(error);
280
+ return {
281
+ content: [{ type: "text", text: message }],
282
+ isError: true,
283
+ };
284
+ }
230
285
  },
231
286
  { "mcp.tool.name": toolName },
232
287
  );
@@ -353,6 +408,12 @@ export class MCPServer {
353
408
  return new dntShim.Response(null, { status: 204, headers: this.getCORSHeaders(requestOrigin) });
354
409
  }
355
410
 
411
+ if (requestOrigin && this.config.cors?.enabled && this.config.cors.origins?.length) {
412
+ if (!this.config.cors.origins.includes(requestOrigin)) {
413
+ return createJSONRPCErrorResponse(403, -32600, "Forbidden: Origin not allowed");
414
+ }
415
+ }
416
+
356
417
  if (this.config.auth?.type && this.config.auth.type !== "none") {
357
418
  const authorized = await this.validateAuth(request);
358
419
  if (!authorized) return new dntShim.Response("Unauthorized", { status: 401 });
@@ -3,6 +3,17 @@ import type { Tool } from "../tool/index.js";
3
3
  import type { Resource } from "../resource/index.js";
4
4
  import type { Prompt } from "../prompt/index.js";
5
5
 
6
+ /**
7
+ * Behavioral hints for MCP clients (MCP 2025-11-25).
8
+ * Guides auto-approval, confirmation prompts, and caching.
9
+ */
10
+ export interface ToolAnnotations {
11
+ readOnlyHint?: boolean;
12
+ destructiveHint?: boolean;
13
+ idempotentHint?: boolean;
14
+ openWorldHint?: boolean;
15
+ }
16
+
6
17
  /**
7
18
  * Generic MCP tool definition
8
19
  */
@@ -13,6 +24,19 @@ export interface MCPTool<TInput = any, TOutput = any> {
13
24
  // deno-lint-ignore no-explicit-any -- ZodType Def/Input params require any for ZodDefault/ZodOptional compatibility
14
25
  inputSchema: z.ZodType<TInput, any, any>;
15
26
  execute: (input: TInput) => Promise<TOutput>;
27
+ title?: string;
28
+ annotations?: ToolAnnotations;
29
+ }
30
+
31
+ /**
32
+ * Wire format for a single tool in a tools/list response.
33
+ */
34
+ export interface ToolListEntry {
35
+ name: string;
36
+ description: string;
37
+ inputSchema: unknown;
38
+ title?: string;
39
+ annotations?: ToolAnnotations;
16
40
  }
17
41
 
18
42
  export interface MCPRegistry {