Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.microsoft.azure.functions</groupId>
<artifactId>azure-functions-java-library</artifactId>
<version>3.2.4</version>
<version>3.3.0</version>
<packaging>jar</packaging>
<parent>
<groupId>com.microsoft.maven</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for
* license information.
*/

package com.microsoft.azure.functions.annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* Defines a strongly-typed input argument for an MCP prompt function parameter.
* <p>
* Alternative to using JSON format in {@link McpPromptTrigger#promptArguments()}.
* Each annotated parameter receives a specific argument value from the prompt invocation.
* Unlike tool properties, prompt arguments are always strings — no type schema is needed.
* </p>
* <p>
* The {@code name()} value serves as both the binding parameter name and the argument name
* exposed in the MCP protocol (the Maven plugin patches it into {@code argumentName} in
* function.json). This follows the same convention as {@link McpToolProperty} where
* {@code name()} is patched into {@code propertyName}.
* </p>
*
* <p>Example:</p>
* <pre>
* {@literal @}FunctionName("codeReview")
* public String codeReview(
* {@literal @}McpPromptTrigger(name = "code_review", description = "Code review prompt") String context,
* {@literal @}McpPromptArgument(
* name = "code",
* description = "The code to review",
* isRequired = true
* ) String code,
* {@literal @}McpPromptArgument(
* name = "language",
* description = "The programming language"
* ) String language
* ) {
* return "Please review the following " + language + " code:\n\n" + code;
* }
* </pre>
*
* @see McpPromptTrigger
* @since 3.3.0
*/
@Target({ElementType.PARAMETER})
@Retention(RetentionPolicy.RUNTIME)
public @interface McpPromptArgument {

/**
* The argument name used as both the binding parameter name and the MCP protocol
* argument identifier. The Maven plugin patches this into {@code argumentName}
* in function.json.
*
* @return The argument name
*/
String name();

/**
* Description of the argument's purpose and usage.
*
* @return Description of the argument
*/
String description() default "";

/**
* Whether this argument is required for prompt invocation.
*
* @return true if required, false if optional
*/
boolean isRequired() default false;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
/**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for
* license information.
*/

package com.microsoft.azure.functions.annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* Triggers an Azure Function when invoked by the Model Context Protocol (MCP) prompt system.
* <p>
* This annotation enables Azure Functions to expose prompt templates that MCP-compatible clients
* can discover via {@code prompts/list} and invoke via {@code prompts/get} with arguments.
* The function returns a plain string (auto-wrapped into a single user message) or a
* JSON-serialized {@code GetPromptResult} for multi-message or rich content responses.
* </p>
*
* <p>Example:</p>
* <pre>
* {@literal @}FunctionName("codeReview")
* public String codeReview(
* {@literal @}McpPromptTrigger(
* name = "code_review",
* description = "Generates a code review prompt"
* ) String context,
* {@literal @}McpPromptArgument(
* name = "code",
* description = "The code to review",
* isRequired = true
* ) String code,
* {@literal @}McpPromptArgument(
* name = "language",
* description = "The programming language"
* ) String language
* ) {
* return "Please review the following " + language + " code:\n\n" + code;
* }
* </pre>
*
* @see McpPromptArgument
* @see McpMetadata
* @since 3.3.0
*/
@Target({ElementType.PARAMETER})
@Retention(RetentionPolicy.RUNTIME)
public @interface McpPromptTrigger {

/**
* The variable name used in function.json and also the unique prompt name
* that MCP clients use to identify and invoke this prompt.
* <p>
* This serves as both the binding parameter name and the prompt identifier.
* It must be unique across all prompts in the function app.
* </p>
*
* @return The prompt name / parameter binding name
*/
String name();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Is name different from promptName?
Per the spec from Lilian:

"name": "<paramName>",
"promptName": "<unique-prompt-name>",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

name() serves as both the binding parameter name and the unique prompt identifier. The Maven plugin PR (#2554) patches it into promptName in function.json. This is the same convention as McpToolTrigger where name() is patched into toolName. Added Javadoc clarifying this.


/**
* Defines how Functions runtime should treat the parameter value. Possible values are:
* <ul>
* <li>"": get the value as a string, and try to deserialize to actual parameter type like POJO</li>
* <li>string: always get the value as a string</li>
* <li>binary: get the value as a binary data, and try to deserialize to actual parameter type byte[]</li>
* </ul>
*
* @return The dataType which will be used by the Functions runtime.
*/
String dataType() default "";

/**
* Human-readable description of what this prompt does.
*
* @return Description of the prompt's purpose
*/
String description() default "";

/**
* Optional human-readable title for display purposes.
*
* @return The display title, or empty string if not specified
*/
String title() default "";

/**
* JSON array defining expected prompt arguments.
* <p>
* Each argument should be a JSON object with: name, description, required.
* Alternative: use {@link McpPromptArgument} annotations on parameters.
* </p>
*
* <p>Example:</p>
* <pre>
* [{"name":"code","description":"The code to review","required":true}]
* </pre>
*
* @return JSON array of argument definitions, or empty string
*/
String promptArguments() default "";
Comment thread
swapnil-nagar marked this conversation as resolved.

/**
* JSON-serialized metadata for the MCP prompt.
*
* @return JSON metadata string, or empty string if not specified
*/
String metadata() default "";

/**
* JSON array of icons for the MCP prompt.
*
* @return JSON array of icon definitions, or empty string if not specified
*/
String icons() default "";
}