-
Notifications
You must be signed in to change notification settings - Fork 5
Implement resource metadata attribute #170
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
base: feature/resources
Are you sure you want to change the base?
Implement resource metadata attribute #170
Conversation
3b0787c to
36a375a
Compare
a14d3f5 to
4be8f99
Compare
36a375a to
ba01930
Compare
4be8f99 to
992e620
Compare
ba01930 to
d4203cc
Compare
992e620 to
a87d5ca
Compare
a87d5ca to
cdf8f0a
Compare
cdf8f0a to
61c0f17
Compare
fabiocav
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The worker surface to support this should be relatively small, right? Can we combine that in the current PR?
src/Microsoft.Azure.Functions.Extensions.Mcp/Trigger/McpResourceTriggerAttribute.cs
Show resolved
Hide resolved
src/Microsoft.Azure.Functions.Extensions.Mcp/Trigger/McpResourceTriggerBinding.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Azure.Functions.Extensions.Mcp/Trigger/McpResourceMetadataAttribute.cs
Show resolved
Hide resolved
| // First check if metadata was serialized from worker model | ||
| if (attribute.Metadata is { } metadataString) | ||
| { | ||
| var metadataList = JsonSerializer.Deserialize<List<KeyValuePair<string, object?>>>(metadataString, McpJsonSerializerOptions.DefaultOptions); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deserialization here if working with <string, object?> may also require special handling. That will be solved if moving to <string, string?>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll investigate the special handling, but I don't think we should do string, string for the reason mentioned above
src/Microsoft.Azure.Functions.Extensions.Mcp/Trigger/McpResourceTriggerBinding.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Azure.Functions.Extensions.Mcp/Trigger/McpResourceTriggerBinding.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Azure.Functions.Extensions.Mcp/Trigger/ResourceReturnValueBinder.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Azure.Functions.Extensions.Mcp/Trigger/ResourceReturnValueBinder.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Azure.Functions.Extensions.Mcp/Trigger/McpResourceTriggerBinding.cs
Outdated
Show resolved
Hide resolved
Yup it's not large, I can include it here |
@fabiocav added the worker side too, but note that I had to add some stuff that is going to be merged in with Aishwarya's PR (like the trigger attrribute). I'll rebase once that is merged. |
| } | ||
|
|
||
| // If metadata is not set in content, use attribute metadata | ||
| // Q: Do we want to implement merge behaviour instead? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question here. I think its fine as is
| @@ -0,0 +1,45 @@ | |||
| // Copyright (c) Microsoft Corporation. All rights reserved. | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dupe from another PR, only change here is addition of:
/// <summary>
/// Gets or sets the serialized resource metadata.
/// </summary>
public string? Metadata { get; set; }
| /// <summary> | ||
| /// Represents the context for an MCP resource invocation. | ||
| /// </summary> | ||
| public sealed class ResourceInvocationContext |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dupe from another PR, can ignore
Issue describing the changes in this PR
resolves #161, #162
Pull request checklist
release_notes.mdAdditional information
Additional PR information