modelcontextprotocol / modelcontextprotocol/typescript-sdk
MCP should return empty instead of error if tools / prompts / resources are not defined
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 13.4k
- Forks
- 2.2k
- Avg merge
- 3d 15h
- Merged PRs (30d)
- 4
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
listPromptsorlistResources
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with an MCP server that defines a tool but no prompts or resources, then call listPrompts and listResources through the client. Trace the collection-listing handlers and related tests, if present; done means every list* method returns an empty array when its collection is undefined, while get* methods still throw errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 66/100