Skip to content

Fix typo in McpPromptRegistry and improve JSON safety#349

Merged
josesimoes merged 1 commit intonanoframework:mainfrom
Vagabond-K:fix/mcp-listing
Apr 2, 2026
Merged

Fix typo in McpPromptRegistry and improve JSON safety#349
josesimoes merged 1 commit intonanoframework:mainfrom
Vagabond-K:fix/mcp-listing

Conversation

@Vagabond-K
Copy link
Copy Markdown
Contributor

Description

  • Fixed a typo from promtps to prompts in McpPromptRegistry.cs.
  • Added a Count > 0 check to prevent exceptions when converting prompts and tools to JSON strings if no items exist. Applied the same safety improvements to McpToolRegistry.cs.

Motivation and Context

  • Found that adding an MCP server fails in Visual Studio when registering MCP tools without prompts, as the absence of prompts causes the '[' character to be omitted from the resulting JSON.
  • Note that in Visual Studio Code, the MCP server was still functional; unlike Visual Studio 2026, it proceeds to fetch the tool list even if the prompt list retrieval fails.

How Has This Been Tested?

nanoFramework.WebServer/tests/McpEndToEndTest/Program.cs

McpToolRegistry.DiscoverTools(new Type[] { typeof(McpServerTests.McpTools) });
Debug.WriteLine("MCP Tools discovered and registered.");

//McpPromptRegistry.DiscoverPrompts(new Type[] { typeof(McpServerTests.McpPrompts) });
//Debug.WriteLine("MCP Prompts discovered and registered.");

Screenshots

  • Visual Studio 2026
    vs2026
  • Visual Studio Code
    vscode

Types of changes

  • Improvement (non-breaking change that improves a feature, code or algorithm)
  • Bug fix (non-breaking change which fixes an issue with code or algorithm)
  • New feature (non-breaking change which adds functionality to code)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Config and build (change in the configuration and build system, has no impact on code or features)
  • Dependencies (update dependencies and changes associated, has no impact on code or features)
  • Unit Tests (add new Unit Test(s) or improved existing one(s), has no impact on code or features)
  • Documentation (changes or updates in the documentation, has no impact on code or features)

Checklist:

  • My code follows the code style of this project (only if there are changes in source code).
  • My changes require an update to the documentation (there are changes that require the docs website to be updated).
  • I have updated the documentation accordingly (the changes require an update on the docs in this repo).
  • I have read the CONTRIBUTING document.
  • I have tested everything locally and all new and existing tests passed (only if there are changes in source code).
  • I have added new tests to cover my changes.

McpPromptRegistry.cs에서 promtps 오타를 prompts로 수정하였고, prompts 및 tools 목록을 JSON 문자열로 변환할 때 항목이 없을 경우 예외가 발생하지 않도록 Count > 0 조건문을 추가했습니다. 동일한 안전성 개선을 McpToolRegistry.cs에도 적용했습니다.
@nfbot nfbot added the Type: Bug label Apr 2, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 2, 2026

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (2)
  • nanoFramework.WebServer.Mcp/McpPromptRegistry.cs is excluded by none and included by none
  • nanoFramework.WebServer.Mcp/McpToolRegistry.cs is excluded by none and included by none

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 28fe24d0-8222-4c75-8ac8-76de704f3c56

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Apr 2, 2026

Copy link
Copy Markdown
Member

@josesimoes josesimoes left a comment

Choose a reason for hiding this comment

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

Nice catch. The typo is on me... 😅

@josesimoes josesimoes enabled auto-merge (squash) April 2, 2026 08:29
@josesimoes josesimoes merged commit b8b9c16 into nanoframework:main Apr 2, 2026
6 checks passed
@Vagabond-K
Copy link
Copy Markdown
Contributor Author

Nice catch. The typo is on me... 😅

😅
Thanks once more for all the work on this project. I think .NET nanoFramework is a fantastic project, and it's been a pleasure to contribute.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants