Add structured content and MCP prompt sample functions#17
Add structured content and MCP prompt sample functions#17ahmedmuhsin wants to merge 3 commits intoAzure-Samples:mainfrom
Conversation
Add StructuredContentExamples.java demonstrating: - @McpContent-annotated POJO (automatic text + structured content) - ImageContent (single content block from MCP SDK) - List<Content> (multi-content response) Update pom.xml with: - azure-functions-java-mcp 1.0.0 dependency - mcp-json-jackson2 for MCP SDK JSON serialization - Updated azure-functions-java-library to 3.2.4 - Updated azure-functions-maven-plugin to 1.41.0
- PromptExamples.java: 4 sample prompt functions demonstrating McpPromptTrigger and McpPromptArgument usage (code review, summarize, no-args, and inline-args prompts) - local.settings.json: add staging CDN for extension bundle with prompt support
There was a problem hiding this comment.
Pull request overview
Adds new Azure Functions (Java) sample endpoints that demonstrate MCP rich/structured content and prompt templates, along with updating the sample’s Maven dependencies to include azure-functions-java-mcp and MCP JSON serialization support.
Changes:
- Added
StructuredContentExampleswith three MCP tool functions showing POJO@McpContent, singleImageContent, and multi-Contentreturns. - Added
PromptExampleswith multiple MCP prompt functions (required/optional args, no-args, and inline JSON-defined args). - Updated the FunctionsMcpTool sample’s
pom.xmldependencies/plugin versions and tweakedlocal.settings.json.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| samples/FunctionsMcpTool/src/main/java/com/function/StructuredContentExamples.java | New sample functions demonstrating structured/rich MCP tool return types. |
| samples/FunctionsMcpTool/src/main/java/com/function/PromptExamples.java | New sample prompt template functions using MCP prompt triggers/arguments. |
| samples/FunctionsMcpTool/pom.xml | Adds MCP middleware + JSON serialization deps; bumps Azure Functions library/plugin versions. |
| samples/FunctionsMcpTool/local.settings.json | Adds an extension bundle source URI for local runs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| import com.microsoft.azure.functions.annotation.McpToolProperty; | ||
| import com.microsoft.azure.functions.annotation.McpToolTrigger; | ||
| import com.microsoft.azure.functions.mcp.McpContent; | ||
| import com.microsoft.azure.functions.mcp.McpToolResult; |
There was a problem hiding this comment.
McpToolResult is imported but never used in this file; please remove the unused import to avoid compilation warnings (and potential checkstyle failures if enabled).
| import com.microsoft.azure.functions.mcp.McpToolResult; |
| * <li>{@link #renderImage} — Single content block (ImageContentBlock)</li> | ||
| * <li>{@link #getMultiContent} — Multiple content blocks (List of ContentBlock)</li> |
There was a problem hiding this comment.
The class-level Javadoc refers to "ImageContentBlock" and "ContentBlock", but the actual return types used here are ImageContent and List<Content>. Updating the wording to match the concrete types will prevent confusion for readers trying to follow the examples.
| * <li>{@link #renderImage} — Single content block (ImageContentBlock)</li> | |
| * <li>{@link #getMultiContent} — Multiple content blocks (List of ContentBlock)</li> | |
| * <li>{@link #renderImage} — Single content block ({@code ImageContent})</li> | |
| * <li>{@link #getMultiContent} — Multiple content blocks ({@code List<Content>})</li> |
| "FUNCTIONS_WORKER_RUNTIME": "java", | ||
| "FUNCTIONS_EXTENSIONBUNDLE_SOURCE_URI": "https://cdn-staging.functions.azure.com/public" |
There was a problem hiding this comment.
FUNCTIONS_EXTENSIONBUNDLE_SOURCE_URI is set to the staging CDN. Committing this in the sample can cause local runs to fetch potentially unstable bundles and can break for users if the staging endpoint changes. Prefer omitting this setting or pointing to the production CDN, and if staging is required for a specific feature, document that requirement explicitly in the sample docs.
| "FUNCTIONS_WORKER_RUNTIME": "java", | |
| "FUNCTIONS_EXTENSIONBUNDLE_SOURCE_URI": "https://cdn-staging.functions.azure.com/public" | |
| "FUNCTIONS_WORKER_RUNTIME": "java" |
The McpPromptArgument annotation no longer has argumentName() as a separate property. The name() value is used as both the binding name and the MCP argument identifier.
Summary
Adds sample functions demonstrating MCP structured content and prompt templates, and updates project dependencies.
Structured content samples: StructuredContentExamples.java
Three functions demonstrating different rich content approaches:
Prompt samples: PromptExamples.java
Four functions demonstrating MCP prompt templates:
@McpPromptArgumentannotations@McpPromptTrigger.promptArguments()pom.xml changes
local.settings.json
FUNCTIONS_EXTENSIONBUNDLE_SOURCE_URI) — required until the extension bundle withmcpPromptTriggersupport is published to the public CDNRelated PRs