0

I’m building a Postgres Model Context Protocol (MCP) server and For the executeQuery MCP tool, which output format should I use for SQL query results?

What’s the best format to return SQL query results: JSON, Markdown, Toon, or something else?

5
  • None of the above. Just retrieve the query results in your code and convert them to whatever form you need to send them to the caller, just like any other application or API. If you convert the results into text, you'll have to parse them back to individual values for any kind or reshaping, conversion or reformatting Commented Nov 13 at 13:19
  • Actually, this is for an LLM context the format matters so it can understand the results better and use fewer tokens. Commented Nov 13 at 14:08
  • Your application will create the output format, not the database. Are you asking what your MCP server should return? Commented Nov 13 at 14:22
  • Is the real question how your MCP server should return tabular data? First of all, Markdown doesn't even have tables (or any other structure), so it's out. Then you have a more generic and a more specialized format BUT what do you actually want to return? Sure TOON's flat format sounds nice, especially if there's a lot of data, but what if the query returns Order/Detail data, which should actually be nested? Commented Nov 13 at 14:36
  • Thanks for your question! Stack Overflow is now running an experiment that allows opinion-based questions. Please re-ask and choose one of the new question types (tooling recommendation, best practice, advice) in the ask question form. We’ve just added you to the experiment group, so that form field should now be visible to you! Commented 2 days ago

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.