Skip to content

Conversation

@ofirncommit
Copy link
Contributor

This PR implements a complete MCP server that provides a get_superhero tool for retrieving superhero details by name or ID. The implementation includes:

  • Superhero data loading from JSON
  • Tool registration with Zod schema validation
  • Case-insensitive name search and ID matching
  • Formatted markdown output for superhero details

@ofirncommit ofirncommit requested a review from Copilot November 4, 2025 17:16
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements a complete MCP (Model Context Protocol) server for querying superhero data. The implementation transforms an empty placeholder file into a fully functional TypeScript-based MCP server that provides superhero information through a tool interface.

  • Adds MCP server setup with tool registration for querying superhero data
  • Implements data loading from JSON file with error handling
  • Adds case-insensitive search functionality by name or ID

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +90 to +94
const hero = superheroes.find(h => {
const heroNameLc = h.name?.toLowerCase() ?? "";
const heroIdStr = h.id?.toString() ?? "";
return heroNameLc === nameLc || heroIdStr === idStr;
});
Copy link

Copilot AI Nov 4, 2025

Choose a reason for hiding this comment

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

The search logic allows matching with empty strings. When both name and id are undefined, nameLc and idStr will be empty strings, and the first hero with an empty/undefined name or id will be returned instead of throwing 'Superhero not found'. Add validation to ensure at least one search parameter is provided before searching.

Copilot uses AI. Check for mistakes.
server.registerTool(
"get_superhero",
{
description: "Get superhero details by name or id",
Copy link

Copilot AI Nov 4, 2025

Choose a reason for hiding this comment

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

The description indicates 'name or id' but the implementation uses OR logic that matches on either field. Consider clarifying that at least one parameter is required, or add validation to enforce this requirement (as noted in the search logic issue).

Copilot uses AI. Check for mistakes.
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