### Start Azurite Storage Emulator (Shell) Source: https://github.com/azure-samples/remote-mcp-functions-python/blob/main/README.md Starts the Azurite Azure Storage Emulator using Docker. This is required for the sample to save and retrieve snippets from blob storage locally. ```shell docker run -p 10000:10000 -p 10001:10001 -p 10002:10002 \ mcr.microsoft.com/azure-storage/azurite ``` -------------------------------- ### Install Python Dependencies (Shell) Source: https://github.com/azure-samples/remote-mcp-functions-python/blob/main/README.md Installs the necessary Python dependencies for the Azure Functions project from the requirements.txt file. It's recommended to use a virtual environment. ```shell cd src pip install -r requirements.txt ``` -------------------------------- ### VS Code Copilot Agent Prompts (Plaintext) Source: https://github.com/azure-samples/remote-mcp-functions-python/blob/main/README.md Examples of prompts to interact with the Copilot agent in VS Code to trigger MCP server functionalities like saving and retrieving code snippets. ```plaintext Say Hello ``` ```plaintext Save this snippet as snippet1 ``` ```plaintext Retrieve snippet1 and apply to newFile.py ``` -------------------------------- ### Start Azure Functions Host (Shell) Source: https://github.com/azure-samples/remote-mcp-functions-python/blob/main/README.md Starts the Azure Functions host locally, making the MCP server accessible via a webhook endpoint. The default endpoint is provided. ```shell func start ``` -------------------------------- ### Enable VNet for Deployment Source: https://github.com/azure-samples/remote-mcp-functions-python/blob/main/README.md This command sets an environment variable to enable Virtual Network (VNet) usage for the deployment. It should be run before executing 'azd up'. ```bash azd env set VNET_ENABLED true ``` -------------------------------- ### Run MCP Inspector (Shell) Source: https://github.com/azure-samples/remote-mcp-functions-python/blob/main/README.md Installs and runs the MCP Inspector tool using Node Package Manager (npm). This tool is used to interact with and inspect the MCP server. ```shell npx @modelcontextprotocol/inspector ``` -------------------------------- ### Deploy to Azure with azd Source: https://github.com/azure-samples/remote-mcp-functions-python/blob/main/README.md This command provisions Azure resources and deploys the application code. It utilizes the Azure Developer CLI (azd) and assumes the project is configured for deployment. ```shell azd up ``` -------------------------------- ### Redeploy Application with azd deploy Source: https://github.com/azure-samples/remote-mcp-functions-python/blob/main/README.md This command deploys the latest code updates to the function app without reprovisioning the Azure resources, useful for iterative development. ```bash azd deploy ``` -------------------------------- ### Get Function App Name and Resource Group Source: https://github.com/azure-samples/remote-mcp-functions-python/blob/main/README.md These bash commands retrieve the Function App Name and Resource Group from the environment configuration file, which are then used for subsequent Azure CLI operations. ```bash # Get your function app name from the environment file FUNCTION_APP_NAME=$(cat .azure/$(cat .azure/config.json | jq -r '.defaultEnvironment')/env.json | jq -r '.FUNCTION_APP_NAME') echo $FUNCTION_APP_NAME # Get resource group RESOURCE_GROUP=$(cat .azure/$(cat .azure/config.json | jq -r '.defaultEnvironment')/env.json | jq -r '.AZURE_RESOURCE_GROUP') echo $RESOURCE_GROUP ``` -------------------------------- ### JSON Azure Functions Host Configuration Source: https://github.com/azure-samples/remote-mcp-functions-python/blob/main/README.md Specifies the `host.json` configuration for an Azure Functions app that utilizes experimental features, specifically referencing the experimental extension bundle required for MCP functionalities. ```json "extensionBundle": { "id": "Microsoft.Azure.Functions.ExtensionBundle.Experimental", "version": "[4.*, 5.0.0)" } ``` -------------------------------- ### Delete Azure Resources with azd down Source: https://github.com/azure-samples/remote-mcp-functions-python/blob/main/README.md This command is used to clean up and delete all provisioned Azure resources associated with the application, preventing further costs. ```shell azd down ``` -------------------------------- ### Download Blob with Azure CLI Source: https://github.com/azure-samples/remote-mcp-functions-python/blob/main/README.md This command downloads a specific blob from the 'snippets' container to a local file path. It requires the Azure CLI, the blob name, a local file path, and the connection string for the emulator. ```shell # Download a specific blob to view its contents az storage blob download --container-name snippets --name --file --connection-string "DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://127.0.0.1:10000/devstoreaccount1;" ``` -------------------------------- ### Python Azure Function: MCP Get Snippet Tool Source: https://github.com/azure-samples/remote-mcp-functions-python/blob/main/README.md Implements an Azure Function in Python for the 'get_snippet' MCP tool. This function reads a snippet from Azure Blob Storage using an input binding and returns its content. It requires the AzureWebJobsStorage connection and a specific blob path. ```python @app.generic_trigger( arg_name="context", type="mcpToolTrigger", toolName="getsnippet", description="Retrieve a snippet by name.", toolProperties=tool_properties_get_snippets_json ) @app.generic_input_binding( arg_name="file", type="blob", connection="AzureWebJobsStorage", path=_BLOB_PATH ) def get_snippet(file: func.InputStream, context) -> str: """ Retrieves a snippet by name from Azure Blob Storage. Args: file (func.InputStream): The input binding to read the snippet from Azure Blob Storage. context: The trigger context containing the input arguments. Returns: str: The content of the snippet or an error message. """ snippet_content = file.read().decode("utf-8") logging.info(f"Retrieved snippet: {snippet_content}") return snippet_content ``` -------------------------------- ### View Function App Logs Source: https://github.com/azure-samples/remote-mcp-functions-python/blob/main/README.md This Azure CLI command streams the logs from the specified function app in real-time, allowing you to monitor application activity and troubleshoot issues. ```bash az webapp log tail --name $FUNCTION_APP_NAME --resource-group $RESOURCE_GROUP ``` -------------------------------- ### List Blobs with Azure CLI Source: https://github.com/azure-samples/remote-mcp-functions-python/blob/main/README.md This command lists all blobs within the 'snippets' container of the local Azure Storage Emulator. It requires the Azure CLI and the connection string for the emulator. ```shell # List blobs in the snippets container az storage blob list --container-name snippets --connection-string "DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://127.0.0.1:10000/devstoreaccount1;" ``` -------------------------------- ### Configure MCP Server for GitHub Copilot in mcp.json Source: https://github.com/azure-samples/remote-mcp-functions-python/blob/main/README.md This JSON configuration is specifically for GitHub Copilot within VS Code. It defines an input for the system key and sets up a server named 'my-mcp-server' using SSE, with the key provided via the 'x-functions-key' header in the request. ```json { "inputs": [ { "type": "promptString", "id": "functions-mcp-extension-system-key", "description": "Azure Functions MCP Extension System Key", "password": true } ], "servers": { "my-mcp-server": { "type": "sse", "url": ".azurewebsites.net/runtime/webhooks/mcp/sse", "headers": { "x-functions-key": "${input:functions-mcp-extension-system-key}" } } } } ``` -------------------------------- ### Python Azure Function: MCP Hello Tool Source: https://github.com/azure-samples/remote-mcp-functions-python/blob/main/README.md Defines a simple Azure Function using Python that acts as an MCP tool named 'hello'. This function returns a basic greeting message and is exposed via MCP function annotations. ```python @app.generic_trigger(arg_name="context", type="mcpToolTrigger", toolName="hello", description="Hello world.", toolProperties="[]") def hello_mcp(context) -> None: """ A simple function that returns a greeting message. Args: context: The trigger context (not used in this function). Returns: str: A greeting message. """ return "Hello I am MCPTool!" ``` -------------------------------- ### Configure MCP Server Connection in mcp.json Source: https://github.com/azure-samples/remote-mcp-functions-python/blob/main/README.md This JSON configuration defines inputs for system key and function app name, and sets up two servers: 'remote-mcp-function' using SSE with a dynamic URL and 'x-functions-key' header, and 'local-mcp-function' for local testing. ```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": "sse", "url": "https://${input:functionapp-name}.azurewebsites.net/runtime/webhooks/mcp/sse", "headers": { "x-functions-key": "${input:functions-mcp-extension-system-key}" } }, "local-mcp-function": { "type": "sse", "url": "http://0.0.0.0:7071/runtime/webhooks/mcp/sse" } } } ``` -------------------------------- ### Connect to Remote MCP Server (MCP Inspector) Source: https://github.com/azure-samples/remote-mcp-functions-python/blob/main/README.md This is a URL format for connecting to the remote MCP server function app from a client, specifically within MCP Inspector. It includes the system key as a query parameter. ```plaintext https://.azurewebsites.net/runtime/webhooks/mcp/sse?code= ``` -------------------------------- ### MCP Inspector SSE Endpoint Configuration (Plaintext) Source: https://github.com/azure-samples/remote-mcp-functions-python/blob/main/README.md Configures the MCP Inspector to use the Server-Sent Events (SSE) transport type and connects to the specified local MCP server endpoint. ```plaintext http://0.0.0.0:7071/runtime/webhooks/mcp/sse ``` -------------------------------- ### Connect to Local MCP Server via SSE (Plaintext) Source: https://github.com/azure-samples/remote-mcp-functions-python/blob/main/README.md Specifies the Server-Sent Events (SSE) endpoint URL for connecting to the locally running Azure Functions MCP server. This URL is used by clients like VS Code Copilot and MCP Inspector. ```plaintext http://0.0.0.0:7071/runtime/webhooks/mcp/sse ``` -------------------------------- ### Python Azure Function: MCP Save Snippet Tool Source: https://github.com/azure-samples/remote-mcp-functions-python/blob/main/README.md Provides a Python Azure Function for the 'save_snippet' MCP tool. This function saves snippet content to Azure Blob Storage using an output binding. It parses snippet name and content from the context and requires the AzureWebJobsStorage connection and a specific blob path. ```python @app.generic_trigger( arg_name="context", type="mcpToolTrigger", toolName="savesnippet", description="Save a snippet with a name.", toolProperties=tool_properties_save_snippets_json ) @app.generic_output_binding( arg_name="file", type="blob", connection="AzureWebJobsStorage", path=_BLOB_PATH ) def save_snippet(file: func.Out[str], context) -> str: content = json.loads(context) snippet_name_from_args = content["arguments"][_SNIPPET_NAME_PROPERTY_NAME] snippet_content_from_args = content["arguments"][_SNIPPET_PROPERTY_NAME] if not snippet_name_from_args: return "No snippet name provided" if not snippet_content_from_args: return "No snippet content provided" file.set(snippet_content_from_args) logging.info(f"Saved snippet: {snippet_content_from_args}") return f"Snippet '{snippet_content_from_args}' saved successfully" ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.