Skip to content

Protocol.Types appears to me missing some very important classes #113

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Rickcau opened this issue Mar 26, 2025 · 1 comment
Closed

Protocol.Types appears to me missing some very important classes #113

Rickcau opened this issue Mar 26, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@Rickcau
Copy link

Rickcau commented Mar 26, 2025

Describe the bug
If trying to declare custom prompt provider I have to create a all the prompt attributes manually, these attributes should be exposed Protocol.Types. Also, when doing so, it also requires you to leverage common classes like Message, MessageContent, TextMessageContent etc. All these types should be exposed via Protocol.Types

To Reproduce
Steps to reproduce the behavior:

  1. Open the AspNetCoreSseServer sample, create a Prompts folder.
  2. Create a CodeReviewPrompts.cs class and paste the following code in the .CS
    3.using AspNetCoreSseServer.Attributes;
    using System.ComponentModel;
    using ModelContextProtocol;
    using ModelContextProtocol.Protocol.Types;
    using ModelContextProtocol.Server;

namespace AspNetCoreSseServer.Prompts
{
// Example prompt type
[McpPromptType]
public static class CodeReviewPrompts
{
[McpPrompt]
[Description("Generate a code review for the given code sample")]
public static IEnumerable ReviewCode(
[McpPromptArgument(Required = true)]
[Description("Code to review")]
string code,

    [McpPromptArgument(Required = false)]
    [Description("Programming language of the code")]
    string language = "csharp")
    {
        // Return a list of messages that form the prompt
        return new List<Message>
    {
        new Message
        {
            Role = "user",
            Content = new List<MessageContent>
            {
                new TextMessageContent
                {
                    Text = $"Please review this {language} code carefully and provide feedback on best practices, potential bugs, and any improvements that could be made:"
                }
            }
        },
        new Message
        {
            Role = "user",
            Content = new List<MessageContent>
            {
                new TextMessageContent
                {
                    Text = $"```{language}\n{code}\n```"
                }
            }
        }
    };
    }

}

What you will find, is that I have to manually create all the classes including the attribute classes as well, which is a lot of repeatable code that can be abstracted away in the package itself.

Expected behavior
By simply referencing the package and adding a using ModelContextProtocol.Protocols.Types all the proper attributes and common classes should be available to me as these will be reused throughout all MCP solutions.

Logs
If applicable, add logs to help explain your problem.

Additional context
Add any other context about the problem here.

@Rickcau Rickcau added the bug Something isn't working label Mar 26, 2025
@stephentoub
Copy link
Contributor

Duplicate of #70

@stephentoub stephentoub marked this as a duplicate of #70 Mar 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants