Skip to content

Add structured content and MCP prompt sample functions#17

Open
ahmedmuhsin wants to merge 3 commits intoAzure-Samples:mainfrom
ahmedmuhsin:feature/mcp-structured-content
Open

Add structured content and MCP prompt sample functions#17
ahmedmuhsin wants to merge 3 commits intoAzure-Samples:mainfrom
ahmedmuhsin:feature/mcp-structured-content

Conversation

@ahmedmuhsin
Copy link
Copy Markdown
Contributor

@ahmedmuhsin ahmedmuhsin commented Mar 16, 2026

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:

  1. GetSnippetStructured - Returns an @McpContent-annotated SnippetResult POJO. The middleware auto-serializes it as both text content (backward compat) and structured content (for clients that support it).
  2. RenderImage - Returns an MCP SDK ImageContent directly. The middleware wraps it as a single image content block.
  3. GetMultiContent - Returns a List of Content with a TextContent + ImageContent. The middleware wraps it as a multi-content result.

Prompt samples: PromptExamples.java

Four functions demonstrating MCP prompt templates:

  1. CodeReviewPrompt - Multi-argument prompt (1 required code arg, 1 optional language arg) using @McpPromptArgument annotations
  2. SummarizePrompt - Single required argument prompt with plain string return
  3. NoArgsPrompt - Prompt with no arguments (edge case)
  4. InlineArgsPrompt - Prompt with arguments defined via inline JSON in @McpPromptTrigger.promptArguments()

pom.xml changes

  • Added azure-functions-java-mcp 1.0.0 dependency
  • Added mcp-json-jackson2 1.1.0 for MCP SDK JSON serialization
  • Updated azure-functions-java-library to 3.2.4
  • Updated azure-functions-maven-plugin to 1.42.0

local.settings.json

  • Added staging CDN (FUNCTIONS_EXTENSIONBUNDLE_SOURCE_URI) — required until the extension bundle with mcpPromptTrigger support is published to the public CDN

Related PRs

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
Copilot AI review requested due to automatic review settings April 21, 2026 18:02
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 StructuredContentExamples with three MCP tool functions showing POJO @McpContent, single ImageContent, and multi-Content returns.
  • Added PromptExamples with multiple MCP prompt functions (required/optional args, no-args, and inline JSON-defined args).
  • Updated the FunctionsMcpTool sample’s pom.xml dependencies/plugin versions and tweaked local.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;
Copy link

Copilot AI Apr 21, 2026

Choose a reason for hiding this comment

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

McpToolResult is imported but never used in this file; please remove the unused import to avoid compilation warnings (and potential checkstyle failures if enabled).

Suggested change
import com.microsoft.azure.functions.mcp.McpToolResult;

Copilot uses AI. Check for mistakes.
Comment on lines +22 to +23
* <li>{@link #renderImage} — Single content block (ImageContentBlock)</li>
* <li>{@link #getMultiContent} — Multiple content blocks (List of ContentBlock)</li>
Copy link

Copilot AI Apr 21, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
* <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>

Copilot uses AI. Check for mistakes.
Comment on lines +5 to +6
"FUNCTIONS_WORKER_RUNTIME": "java",
"FUNCTIONS_EXTENSIONBUNDLE_SOURCE_URI": "https://cdn-staging.functions.azure.com/public"
Copy link

Copilot AI Apr 21, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
"FUNCTIONS_WORKER_RUNTIME": "java",
"FUNCTIONS_EXTENSIONBUNDLE_SOURCE_URI": "https://cdn-staging.functions.azure.com/public"
"FUNCTIONS_WORKER_RUNTIME": "java"

Copilot uses AI. Check for mistakes.
@ahmedmuhsin ahmedmuhsin changed the title Add structured content sample functions and azure-functions-java-mcp dependency Add structured content and MCP prompt sample functions Apr 21, 2026
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants