Skip to content

Commit ddf03ad

Browse files
committed
fix(cli): submit MCP prompt text without JSON encoding
1 parent 87a9c71 commit ddf03ad

2 files changed

Lines changed: 21 additions & 2 deletions

File tree

packages/cli/src/services/McpPromptLoader.test.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,26 @@ describe('McpPromptLoader', () => {
222222
});
223223
expect(result).toEqual({
224224
type: 'submit_prompt',
225-
content: JSON.stringify('Hello, world!'),
225+
content: 'Hello, world!',
226+
});
227+
});
228+
229+
it('should preserve quotes and newlines in prompt response text', async () => {
230+
const promptText = 'He said "hello".\nNext line';
231+
mockPrompt.invoke.mockResolvedValueOnce({
232+
messages: [{ content: { type: 'text', text: promptText } }],
233+
});
234+
235+
const loader = new McpPromptLoader(mockConfigWithPrompts);
236+
const commands = await loader.loadCommands(new AbortController().signal);
237+
const result = await commands[0].action!(
238+
{} as CommandContext,
239+
'test-name 123 tiger',
240+
);
241+
242+
expect(result).toEqual({
243+
type: 'submit_prompt',
244+
content: promptText,
226245
});
227246
});
228247

packages/cli/src/services/McpPromptLoader.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ export class McpPromptLoader implements ICommandLoader {
139139

140140
return {
141141
type: 'submit_prompt',
142-
content: JSON.stringify(maybeContent.text),
142+
content: maybeContent.text,
143143
};
144144
} catch (error) {
145145
return {

0 commit comments

Comments
 (0)