Agent Wealth HubFree public resources
中文 EN العربية

Back to catalog / MCP servers

Build a read-only MCP tool server for agent queries

Expose a narrowly scoped query tool so MCP clients can read application data but cannot change it.

Goal

Provide discoverable, constrained MCP queries with no write side effects.

Steps

  1. Choose one read-only business query and grant minimum read privileges at the data layer. [mcp-tools] [mcp-errors]
  2. Register with @mcp.tool() and type hints; constrain pagination with Annotated[int, Field(ge=1, le=50)]. [mcp-tools] [mcp-errors]
  3. If you set read_only_hint=True, treat it only as a client hint; enforce read-only access in database/service permissions. [mcp-tools] [mcp-errors]
  4. Convert exceptions to controlled MCP errors; never return stack traces, connection strings, or secrets. [mcp-tools] [mcp-errors]
  5. Test valid, unauthorized, invalid, and oversized-page requests; verify the data layer rejects writes. [mcp-tools] [mcp-errors]

How to verify

Tests should prove the tool reads only authorized scope and errors reveal no internal details.

Troubleshooting

If a test can mutate data, enforce read-only permissions in the data layer rather than relying on the tool description.

Permissions

Prerequisites

Permissions

Limitations

SDK behavior varies by version. Check the pinned revision against your agent or client, then review data retention, authorization, and side effects before production use.

Pinned upstream source

https://github.com/modelcontextprotocol/python-sdk/blob/754254c08fe1c3eda18b69da3d336106fe8d72d6/docs/servers/tools.md

Repository
modelcontextprotocol/python-sdk
File path
docs/servers/tools.md
Pinned commit
754254c08fe1c3eda18b69da3d336106fe8d72d6
Source checked
2026-10-14 · Reviewed against the pinned upstream source

Repository metrics

These values describe the upstream repository, not popularity or likes for an individual skill or playbook.

Stars
Not collected
Forks
Not collected
Observed at
Not collected

No metrics snapshot is available yet.

License: MIT

Main topic

When to use a Skill or MCP

Related resources