@elliotding/ai-agent-mcp 0.1.24 → 0.1.25

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.
@@ -0,0 +1,113 @@
1
+ /**
2
+ * resolve_prompt_content Tool
3
+ *
4
+ * Stable fallback for retrieving the fully resolved body of a dynamically
5
+ * subscribed Command or Skill without relying on Cursor to issue prompts/get.
6
+ */
7
+
8
+ import { logger } from '../utils/logger';
9
+ import { promptManager } from '../prompts/index.js';
10
+ import type {
11
+ ResolvePromptContentParams,
12
+ ResolvePromptContentResult,
13
+ ToolResult,
14
+ } from '../types/tools';
15
+
16
+ export async function resolvePromptContent(
17
+ params: unknown,
18
+ ): Promise<ToolResult<ResolvePromptContentResult>> {
19
+ const p = params as ResolvePromptContentParams;
20
+ const promptName = typeof p.prompt_name === 'string' && p.prompt_name.trim() !== ''
21
+ ? p.prompt_name.trim()
22
+ : undefined;
23
+ const resourceId = typeof p.resource_id === 'string' && p.resource_id.trim() !== ''
24
+ ? p.resource_id.trim()
25
+ : undefined;
26
+ const userToken = typeof p.user_token === 'string' ? p.user_token : '';
27
+ const jiraId = typeof p.jira_id === 'string' && p.jira_id.trim() !== ''
28
+ ? p.jira_id.trim()
29
+ : undefined;
30
+
31
+ if (!promptName && !resourceId) {
32
+ return {
33
+ success: false,
34
+ error: {
35
+ code: 'VALIDATION_ERROR',
36
+ message: 'Either prompt_name or resource_id is required',
37
+ },
38
+ };
39
+ }
40
+
41
+ const resolved = await promptManager.resolvePromptContentForInvocation({
42
+ promptName,
43
+ resourceId,
44
+ userToken,
45
+ jiraId,
46
+ });
47
+
48
+ if (!resolved) {
49
+ const target = promptName ?? resourceId ?? 'unknown';
50
+ logger.warn({ promptName, resourceId }, 'resolve_prompt_content: prompt not found');
51
+ return {
52
+ success: false,
53
+ error: {
54
+ code: 'PROMPT_NOT_FOUND',
55
+ message: `Prompt "${target}" is not available. Please run sync_resources first.`,
56
+ },
57
+ };
58
+ }
59
+
60
+ logger.info(
61
+ {
62
+ promptName: resolved.promptName,
63
+ resourceId: resolved.meta.resource_id,
64
+ contentSource: resolved.contentSource,
65
+ },
66
+ 'resolve_prompt_content: prompt resolved successfully',
67
+ );
68
+
69
+ return {
70
+ success: true,
71
+ data: {
72
+ prompt_name: resolved.promptName,
73
+ resource_id: resolved.meta.resource_id,
74
+ resource_type: resolved.meta.resource_type,
75
+ resource_name: resolved.meta.resource_name,
76
+ description: resolved.description,
77
+ content: resolved.content,
78
+ content_source: resolved.contentSource,
79
+ usage_tracked: Boolean(userToken),
80
+ },
81
+ };
82
+ }
83
+
84
+ export const resolvePromptContentTool = {
85
+ name: 'resolve_prompt_content',
86
+ description:
87
+ 'Retrieve the fully resolved content of a Command or Skill prompt without relying on native prompts/get. ' +
88
+ 'Use this immediately after search_resources -> manage_subscription -> sync_resources when you need the prompt body in the same workflow. ' +
89
+ 'Provide either prompt_name (for example "command/acm-helper") or resource_id. ' +
90
+ 'user_token is injected automatically by the server; do NOT ask the user for it.',
91
+ inputSchema: {
92
+ type: 'object' as const,
93
+ properties: {
94
+ prompt_name: {
95
+ type: 'string',
96
+ description: 'Registered MCP prompt name, for example "command/acm-helper".',
97
+ },
98
+ resource_id: {
99
+ type: 'string',
100
+ description: 'Canonical CSP resource ID for the Command or Skill.',
101
+ },
102
+ user_token: {
103
+ type: 'string',
104
+ description: 'DO NOT set this field — it is injected automatically by the server.',
105
+ },
106
+ jira_id: {
107
+ type: 'string',
108
+ description: 'Optional Jira issue ID for usage correlation.',
109
+ },
110
+ },
111
+ },
112
+ handler: resolvePromptContent,
113
+ };
@@ -769,6 +769,8 @@ export const syncResourcesTool = {
769
769
  description:
770
770
  'Synchronize subscribed AI resources. ' +
771
771
  'Command and Skill resources are registered as MCP Prompts on the server. ' +
772
+ 'If the user subscribed to a NEW Command or Skill in THIS conversation and you need to execute it immediately, do NOT wait for native prompts/get. ' +
773
+ 'After this tool completes, call `resolve_prompt_content` with the new prompt_name or resource_id, then execute the returned content. ' +
772
774
  'Rule and MCP resources are returned as `local_actions_required` — an ordered list of ' +
773
775
  'write_file, merge_mcp_json, or other actions that the AI Agent MUST execute on the ' +
774
776
  'USER\'S LOCAL MACHINE after receiving the response. ' +
@@ -219,6 +219,27 @@ export interface SearchResourcesResult {
219
219
  }>;
220
220
  }
221
221
 
222
+ // resolve_prompt_content
223
+ export interface ResolvePromptContentParams {
224
+ prompt_name?: string;
225
+ resource_id?: string;
226
+ /** CSP API token from the user's mcp.json env configuration. */
227
+ user_token?: string;
228
+ /** Optional Jira Issue ID for usage correlation. */
229
+ jira_id?: string;
230
+ }
231
+
232
+ export interface ResolvePromptContentResult {
233
+ prompt_name: string;
234
+ resource_id: string;
235
+ resource_type: 'command' | 'skill';
236
+ resource_name: string;
237
+ description: string;
238
+ content: string;
239
+ content_source: 'cache' | 'generated' | 'raw_fallback';
240
+ usage_tracked: boolean;
241
+ }
242
+
222
243
  // upload_resource
223
244
  export interface FileEntry {
224
245
  path: string; // Relative path under the type subdir (e.g. "my-cmd.md" or "code-review/SKILL.md")