Description
Describe the bug
Currently, if you set up a server with the tools defined, but no prompts / resources, attempting to get tools/resources will throw an error instead of returning empty.
To Reproduce
Steps to reproduce the behavior:
- Set up an MCP server + client
- Define a test tool
- Try calling
listPrompts
orlistResources
Expected behavior
All list*
methods (that return collections) should return empty arrays when there is nothing to return.
get*
should throw an error.
Logs
Additional context
Returning an empty array is a idiomatic pattern when a collection of items is empty.
Express.js
When you query routes that don't match anything, Express returns a 404 rather than crashing
app.get('/api/items') will return an empty array [] when no items exist, not an error
React
When mapping over an empty array of items, React doesn't throw errors - it renders nothing
{items.map(item => <Component key={item.id} {...item} />)} works fine when items is empty
PostgreSQL / Sequelize
User.findAll() returns an empty array if no users exist
It only throws if the table itself doesn't exist (which would be a structural issue)
Next.js
getStaticPaths() can return an empty array if there are no dynamic routes
It doesn't error out because an empty set of paths is valid
Redux
Selectors return empty arrays or default values when querying state that doesn't exist
const todos = useSelector(state => state.todos || []) handles missing state gracefully