Skip to content

Self-hosted MCP: Create experience #4749

@lilyjma

Description

@lilyjma

Ask summary

For the Azure Functions: Create new project command, create a new project type called "Self-hosted MCP server" and remove "Ballerina":

Image

When "Self-hosted MCP server" is picked, prompt the user with the following:

  1. Select server language: Python, TypeScript, .NET
  2. Include sample server code: Yes, No

Include sample server code is: No

  1. host.json
{
    "version": "2.0",
    "configurationProfile": "mcp-custom-handler",
    "customHandler": {
        "description": {
            "defaultExecutablePath": "",
            "arguments": [""] 
        }
    }
}	
  1. local.settings.json, FUNCTIONS_WORKER_RUNTIME depends on the server language
{
    "IsEncrypted": false,
    "Values": {
        "FUNCTIONS_WORKER_RUNTIME": "<python|node|dotnet-isolated>",
        "AzureWebJobsFeatureFlags": "EnableMcpCustomHandlerPreview”
    }
}

Include sample server code is: Yes

  1. Depending on the language, include simple MCP server snippet:
# TODO: provide Python, TypeScript, and C# code snippets
  1. Fill in the values for properties defaultExecutablePath and arguments in host.json:
    Language defaultExecutablePath arguments
    Python python ["server.py"]
    TypeScript npm ["run", "start"]
    .NET dotnet ["server.dll"]
  2. local.settings.json should be same as above, with the right FUNCTIONS_WORKER_RUNTIME
  3. Different languages require extra files:
    Server language File included
    Python pyproject.toml
    TypeScript package.json, tsconfig.json
    C# .csproj

TODO: provide file content

Other requirements

This is very important!

  • .vscode/settings.json needs to be generated properly, especially azureFunctions.projectLanguage. The server wouldn't deploy properly if the value is custom.

    For projects created in VSCode, the language can be inferred by the answer to the prompt during project creation. However, for projects created outside of VSCode, this can't be done, so user should be prompted to provide that.

  • Upload the AzureWebJobsFeatureFlags to the app (otherwise deployment will fail)

E2E flow summary

  1. Customer runs Azure Functions: Create new project command
  2. Project type prompt
  3. Server language prompt
  4. Include sample code prompt
  5. New project is created with the right files and content

Not in scope

  • Make F5 debugging work. The debugger needs to attach to the child process. Tracking this in another issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions