Skip to content

Conversation

@noahsprent
Copy link

The current tools aren't powerful enough for an LLM to properly investigate the database, or even fetch the most recent readings for certain sensors. This adds a tool that enables more more flexibility, but hopefully is still safe.


@mcp.tool()
@wrap_result_as_dict
def db_list_rows(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I agree the current db_query_table is too limited. However I think this solution is too heavy-handed in the other direction. I think this article explains the idea of "let LLMs write code" well: https://lucumr.pocoo.org/2025/8/18/code-mcps/

In summary: LLMs are really good at writing SQL statement, lets just give them that option. I'm thinking something as general as:

def query_db(query: str)

(and we do some small validation to ensure it's a read-only query => edits aren't allowed against the db).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool yes, totally agree with that approach. Wasn't sure how easy the validation would be. Then I guess for adding to/editing the DBs the tools would be much more bespoke like 'add OD reading' 'edit experiment details' or something with lots of checks. I have no affinity with the actual code here, just thought it was more helpful to give an actual example that worked for me rather than write an issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants