Add a new module for MCP specific traits with Prompts trait#817
Add a new module for MCP specific traits with Prompts trait#817adwsingh merged 6 commits intosmithy-lang:mainfrom
Conversation
… Smithy services. Includes prompt templates, parameter descriptions, and usage conditions for services, resources, and operations.
| @@ -0,0 +1,33 @@ | |||
| $version: "2" | |||
|
|
|||
| namespace amazon.smithy.llm | |||
There was a problem hiding this comment.
IDK, these feel very MCP specific and I wouldn't like to name something tied to a particular model architecture.
Either we keep the namespace as software.amazon.smithy.mcp or software.amazon.smtihy.ai
There was a problem hiding this comment.
I discussed with @mtdowling and we are going to be placing these in smithy.llm following the patterns for smithy.api, smithy.rules , etc.
There was a problem hiding this comment.
Right now that change is blocked on a PR to update logic on trait-codegen plugin restrictions being flexible.
Also this namespace is pretty changeable. The software.amazon.smithy.llm will be the package name used for the Java classes generated off it.
There was a problem hiding this comment.
llm is technically incorrect. These traits are for use with generative AI, but llm refers to a specific type of model architecture.
There was a problem hiding this comment.
Hmm. So how about smithy.ai ?
There was a problem hiding this comment.
And for the package name for java class as software.amazon.smtihy.ai ?
There was a problem hiding this comment.
@mtdowling and @kstich you good with the naming?
The selector had incorrect syntax from my local testing where it would really only be applied to a service shape. This corrects it.
| } | ||
|
|
||
| /// Defines the structure of the prompt | ||
| structure PromptTemplateDefinition { |
There was a problem hiding this comment.
Ack. Will update with the namespace update PR.
| } | ||
|
|
||
| @idRef(failWhenMissing: true, selector: "structure") | ||
| string ArgumentShape |
There was a problem hiding this comment.
Ack. Will update with the namespace update PR.
|
|
||
| // Prompt template trait - applied at operation level to provide guidance to LLMs | ||
| @trait(selector: ":is(service, resource, operation)") | ||
| map prompts { |
There was a problem hiding this comment.
The seems MCP specific, @mcpPrompts?
There was a problem hiding this comment.
We want to avoid directly naming any protocols in case we support more in the future
This PR introduces a new @prompts trait that enables Smithy service authors to provide contextual guidance for Large Language Models (LLMs) when interacting with their services. The trait can be applied to services, resources, and operations to define prompt templates, parameter descriptions, and usage conditions.
The logic for using the data from the traits to serve prompts as part of the MCP server will be a separate PR.
Key features:
• Prompt Templates: Define template text with placeholders for parameters and multi-operation workflows
• Parameter Guidance: Optional argument descriptions to help LLMs understand parameter usage
• Conditional Usage: Specify when certain operations should be preferred over others
• Flexible Application: Can be applied at service, resource, or operation level
Added an example that builds.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.