azure function hosting mcp server

Run the following command to create the azure function with mcp 

azd init --template remote-mcp-functions-python -e mcpserver-python

Once you have finish, go to the root folder where you will see pyproject.toml and azure.yaml, etc.

Then start vscode. Make sure you have the pre-requisites like Azure function Developer tool and azurite all setup. 

From vscode, select "Debug". It will prompt you to create a virtual environment. Please select "yes". When it ask you to run azurite - please select yes. 


Running the MCP function app

Next run the function app. You have to go into the src folder first and run vscode. 

Then you will be prompted to create an environment. Hit F5 or Run -> Debug. that will install your python modules under requirements.txt. 


Launch MCP Server

Next we will lanch our mcp server by creating a file call mcp.json.


{
    "inputs": [
        {
            "type": "promptString",
            "id": "functions-mcp-extension-system-key",
            "description": "Azure Functions MCP Extension System Key",
            "password": true
        },
        {
            "type": "promptString",
            "id": "functionapp-name",
            "description": "Azure Functions App Name"
        }
    ],
    "servers": {
        "remote-mcp-function": {
            "type": "http",
            "url": "https://${input:functionapp-name}.azurewebsites.net/runtime/webhooks/mcp",
            "headers": {
                "x-functions-key": "${input:functions-mcp-extension-system-key}"
            }
        },
        "local-mcp-function": {
            "type": "http",
            "url": "http://0.0.0.0:7071/runtime/webhooks/mcp"
        }
    }

} 

And you can see it here



Goto local-mcp-function and click "Run"



From the chat window, we issue a "say hello". Then the chatbot will ask for permission to use mcp tool.

Ensure you have configure the chatbox correctly. Ensure it is agent mode and then click on "Configure tools" you can see mcp-local-function, as shown here

Next we will configure the chatbox



And as you can see from here, we are able to hit the azure function mcp server hello_mcp function and it is also asking for permission.



And finally we can see the outputs:- 






Comments

Popular posts from this blog

vllm : Failed to infer device type

NodeJS: Error: spawn EINVAL in window for node version 20.20 and 18.20

android studio kotlin source is null error