bnb-mcp-java-az-server

ninckblokje/bnb-mcp-java-az-server

3.2

If you are the rightful owner of bnb-mcp-java-az-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.

The Model Context Protocol (MCP) server is a framework designed to facilitate the interaction between AI agents and various tools or resources using a standardized protocol.

Tools
3
Resources
0
Prompts
0

Bits 'n Bites MCP server in Java (deployed to Azure Functions)

Requirements

  • Azure CLI
  • Azure Functions Core Tools
  • Java 21
  • Access to SynTouch Azure subscription SynTouch-Speeltuin
  • Visual Studio Code + GitHub Copilot

Instructions

First build the project: ./mvnw clean package

The basic structure has already been provided as a Maven project:

  • The class will be used to implement the Tools
  • The contains the correct dependencies and plugins:
    • The library azure-functions-java-library should be version 3.2.2 or higher
    • The plugin azure-functions-maven-plugin should be version 1.40.0 or higher
    • ‼️ Older version will not generate the required metadata for MCP to be correctly deployed ‼️
  • The file specifies which extensions are available to the Azure Function
  • The file allows the Azure Function to run locally
  • In the file MCP server can be configured

You are going to implement three tools which can be used by an AI agent using the MCP protocol.

In the file set the following properties:

  • prefix: For example your name
  • resourceGroup: Your resource group to deploy the Azure Function

Open the class and add the following method:

    @FunctionName("HelloWorldTool")
    public String helloWorld(
            @McpToolTrigger(
                name = "HelloWorldTool",
                description = "A simple tool that says: Hello World!"
            ) String triggerInput,
            final ExecutionContext context) {
        context.getLogger().info("Hello World Tool invoked.");
        return "Hello World!";
    }

This will define a new function (named HelloWorldTool), with an MCP tool trigger (also named HelloWorldTool). The trigger annotation will let Azure Functions know how this method is going to be called.

Rebuild the project and start it:

./mvnw clean package
./mvnw azure-functions:run

The function should have successfully started and show the available MCP tools:

Functions:

	HelloWorldTool: mcpToolTrigger

The build step generated metadata for Azure Functions, which can be found in the folder .

An HTTP endpoint and a SSE endpoint are automatically exposed. Since SSE is deprecated for MCP servers, we will use the HTTP endpoint: http://localhost:7071/runtime/webhooks/mcp Open the file and replace the content:

{
    "inputs": [],
    "servers": {
        "bnb-mcp-java-az-server-local": {
            "url": "http://localhost:7071/runtime/webhooks/mcp",
            "type": "http"
        }
    }
}

In the same file you can start the MCP server. Visual Studio Code will then automatically load the available tools.

Open a new chat in Visual Studio Code. Add the correct context using the paperclip, select Tools and select bnb-mcp-java-az-server-local.

Using the following prompt test the function and accept all security risks 😉: ``

The stdout should show this log line: Hello World Tool invoked.

Stop the Java process and implement two more MCP tools by adding these methods to :

    @FunctionName("MultiplyNumbersTool")
    public Long multiplyNumbers(
            @McpToolTrigger(
                name = "MultiplyNumbersTool",
                description = "A tool that shows parameter usage by asking for two numbers and multiplying them together"
            ) String triggerInput,
            @McpToolProperty(
                    name = "FirstNumber",
                    description = "The first number to multiply",
                    propertyType = "number"
            ) Long firstNumber,
            @McpToolProperty(
                    name = "SecondNumber",
                    description = "The second number to multiply",
                    propertyType = "number"
            ) Long secondNumber,
            final ExecutionContext context) {
        context.getLogger().info("Multiply Numbers Tool invoked, with: %d and %d".formatted(firstNumber, secondNumber));
        return firstNumber * secondNumber;
    }

    @FunctionName("ReverseMessageTool")
    public String reverseString(
        @McpToolTrigger(
                    name = "ReverseMessageTool",
                    description = "Echoes back message in reverse"
            ) String mcpToolInvocationContext,
            @McpToolProperty(
                    name = "Message",
                    description = "The Message to reverse",
                    propertyType = "string"
            ) String message,
            final ExecutionContext context
    ) {
        context.getLogger().info("Reverse Message Tool invoked, with: %s".formatted(message));
        return new StringBuilder(message)
                .reverse()
                .toString();
    }

Rebuild the project and start it. Now restart the MCP server in Visual Studio Code (in the file ).

Open a new chat and using the following tests the two other MCP tools:

  • Multiply 3 by 4
  • Reverse the string "#C neht retteb si avaJ"

Stop the MCP server in Visual Studio Code and kill the Java process. Now we can deploy the Azure Function to Azure. This is all handled by the Maven plugin:

az login
./mvnw azure-functions:deploy

Application Insights, a storage account and the Azure Function are automically created before your code is deployed.

In the Azure Portal, the deployed MCP tools should be visible on your Azure Function:

To call the deployed MCP tools replace the content of :

{
    "inputs": [
        {
            "type" :"promptString",
            "id": "functions-default-domain",
            "description": "Azure Functions Default Domain",
        },
        {
            "type": "promptString",
            "id": "functions-mcp-extension-system-key",
            "description": "Azure Functions MCP Extension System Key",
            "password": true
        }
    ],
    "servers": {
        "bnb-mcp-java-az-server-local": {
            "url": "http://localhost:7071/runtime/webhooks/mcp",
            "type": "http"
        },
        "bnb-mcp-java-az-server-azure": {
            "url": "https://${input:functions-default-domain}/runtime/webhooks/mcp",
            "type": "http",
            "headers": {
                "x-functions-key": "${input:functions-mcp-extension-system-key}"
            }
        }
    }
}

Start the MCP server bnb-mcp-java-az-server-azure and Visual Studio Code will prompt for two variables:

  • functions-default-domain: Use the Default domain value from the Overview page
  • functions-mcp-extension-system-key: Use the value for the system key mcp_extension, which can be found by opening Functions and clicking on App keys

Now use the same prompts as earlier to test the MCP tools deployed to Azure (you might need to set the context again).