Title: Response format schema for prompts · Issue #249 · modelcontextprotocol/modelcontextprotocol · GitHub
Open Graph Title: Response format schema for prompts · Issue #249 · modelcontextprotocol/modelcontextprotocol
X Title: Response format schema for prompts · Issue #249 · modelcontextprotocol/modelcontextprotocol
Description: Is your feature request related to a problem? Please describe. Currently, I am developing an MCP server that manages prompt templates for parameterized invocation by clients. The current implementation follows a pattern like promptsHolde...
Open Graph Description: Is your feature request related to a problem? Please describe. Currently, I am developing an MCP server that manages prompt templates for parameterized invocation by clients. The current implementa...
X Description: Is your feature request related to a problem? Please describe. Currently, I am developing an MCP server that manages prompt templates for parameterized invocation by clients. The current implementa...
Opengraph URL: https://github.com/modelcontextprotocol/modelcontextprotocol/issues/249
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Response format schema for prompts","articleBody":"**Is your feature request related to a problem? Please describe.**\nCurrently, I am developing an MCP server that manages prompt templates for parameterized invocation by clients. The current implementation follows a pattern like `promptsHolder.getPrompt({name: \"myPrompt\", arguments: {...}})`, which returns an array of messages to send to the LLM agent.\n\nSome of my prompts require a specific output format from the LLM. At present, I rely on few-shot prompting techniques to enforse desired structured output. However, this approach sometimes leads to inconsistent results, such as not expected enums values, or markdown-style quotation.\n\n**Describe the solution you'd like**\nI propose that the MCP server should be able to specify a JSON schema for the expected response. The schema definition would take place on the server side, while the client would handle the final adaptation for specific host models. A common option to consider could be [response_format](https://platform.openai.com/docs/guides/structured-outputs?api-mode=chat). \n\nA potential implementation might look like this:\n\u003e /server/api/getPrompt/myPrompt\n```\n{\n \"jsonrpc\": \"2.0\",\n \"id\": 2,\n \"result\": {\n \"description\": \"Code review prompt\",\n \"options\": {\n \"response_format\": {\"type\": \"json_object\", \"schema\": __jsonSchema__},\n }\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": {\n \"type\": \"text\",\n \"text\": \"Please review this Python code:\\ndef hello():\\n print('world')\"\n }\n }\n ]\n }\n}\n```\n\n**Describe alternatives you've considered**\n- few shots prompting, that works in most cases, but misfires time to time \n- tool calling, when the tool with structured params definition is provided to the model — this is common workaround, and even anthropic [recommended](https://docs.anthropic.com/en/docs/build-with-claude/tool-use/overview#json-output) to use it as claude does not accept a schema parameter, but it still a workaround which add unnecessary complexity\n\n**Additional context**\nThere is related discussion https://github.com/modelcontextprotocol/specification/issues/97 and even same question is [raised](https://github.com/modelcontextprotocol/specification/issues/97#issuecomment-2539110532), but that topic is generally consider another feature.\n\nI understand that such feature significantly increases API-surface. And at least raise some questions. \n\nServer can't be sure for 100% that client or host implement that feature. So it need to proceed validation on own side and even raise errors. Should it be reflected in protocol somehow? Like a requirement from the client to inform the server about the available options.\n\nWould appreciate your thoughts about this feature. Would it be on roadmap or better to consider alternative options?","author":{"url":"https://github.com/gleb-lobastov","@type":"Person","name":"gleb-lobastov"},"datePublished":"2025-03-28T10:46:30.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":6},"url":"https://github.com/249/modelcontextprotocol/issues/249"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:f8f39a0c-5f68-3e38-ea5d-cbf8813e578d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D964:29812D:2451FB2:30F4219:6A59B0B6 |
| html-safe-nonce | 2b98baae6186dd3d00061b53a753b0b21dd0e37c353ae0fdb8ad580d240ca77c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEOTY0OjI5ODEyRDoyNDUxRkIyOjMwRjQyMTk6NkE1OUIwQjYiLCJ2aXNpdG9yX2lkIjoiNDU3MzgyMDI1Mjc5NTI4NTY4NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 1932acc31ea5f420707537d62fb19634e13e16ddd477fa22d83871bc678b0536 |
| hovercard-subject-tag | issue:2955767343 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/modelcontextprotocol/modelcontextprotocol/249/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3c590e9b63a1c00fb3106e1f2ec2eeae355605e20c2cd969ff8745585a84783b/modelcontextprotocol/modelcontextprotocol/issues/249 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3c590e9b63a1c00fb3106e1f2ec2eeae355605e20c2cd969ff8745585a84783b/modelcontextprotocol/modelcontextprotocol/issues/249 |
| og:image:alt | Is your feature request related to a problem? Please describe. Currently, I am developing an MCP server that manages prompt templates for parameterized invocation by clients. The current implementa... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | gleb-lobastov |
| hostname | github.com |
| expected-hostname | github.com |
| None | ba3976babb66479b1c943a8edc0777d96157da48fadc0161f9ddb219deee8353 |
| turbo-cache-control | no-preview |
| go-import | github.com/modelcontextprotocol/modelcontextprotocol git https://github.com/modelcontextprotocol/modelcontextprotocol.git |
| octolytics-dimension-user_id | 182288589 |
| octolytics-dimension-user_login | modelcontextprotocol |
| octolytics-dimension-repository_id | 862570523 |
| octolytics-dimension-repository_nwo | modelcontextprotocol/modelcontextprotocol |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 862570523 |
| octolytics-dimension-repository_network_root_nwo | modelcontextprotocol/modelcontextprotocol |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | ab680789ae4a316cdaf0d5a292a1760140931cc4 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width