Skip to content

[Feature request] Scaffold MCP server project with func init #4610

@lilyjma

Description

@lilyjma

Problem Statement

Developers who want to deploy a self-hosted MCP server currently need to manually add Function artifacts to their project. This involves creating and populating host.json and local.settings.json with the appropriate defaults. Manual setup is error-prone and slows down onboarding. We propose to introduce a new flag, --configurationProfile, to the func init command, streamlining this process.

User Experience

Minimal Example

In an existing MCP server project, a developer runs:

func init --configurationProfile mcp-custom-handler --worker-runtime <python|node|dotnet>

The command scaffolds the project with the following files and settings:

host.json

{
    "version": "2.0",
    "configurationProfile": "mcp-custom-handler",
    "customHandler": {
        "description": {
            "defaultExecutablePath": "",
            "arguments": []
        }
    }
}

local.settings.json

{
    "IsEncrypted": false,
    "Values": {
        "FUNCTIONS_WORKER_RUNTIME": "<python|node|dotnet-isolated>",
        "AzureWebJobsFeatureFlags": "EnableMcpCustomHandlerPreview"
    }
}
  • The language value is set based on the --worker-runtime flag.
  • The feature flag for MCP custom handler is set.

Requirements

  • New flag: Add --configurationProfile to the func init command.
  • Supported value: Only mcp-custom-handler is supported for now. Other values are invalid and should be rejected with a clear error.
  • Validation: If an unsupported configurationProfile value is provided, the CLI should fail with an error message:
    "configurationProfile '<value>' is not supported. Supported values: mcp-custom-handler."
  • File Output:
    • Generate a host.json file with the profile and relevant defaults.
    • Generate a local.settings.json file with the proper worker runtime and feature flag.
  • Override Precedence: If the files already exist, do not overwrite them; warn the user or prompt for overwrite.
  • Extensibility: Future profiles may be added; for now, extensibility is out-of-scope.

func pack requirements

Acceptance Criteria

  • Running func init --configurationProfile mcp-custom-handler --worker-runtime <python|node|dotnet> in a project creates a host.json and local.settings.json as specified, with the correct values substituted.
  • The CLI fails with a clear error for unsupported --configurationProfile values.
  • Running the command in a directory with existing config files does not overwrite them without user consent.

Testing plan

  • Regression: Ensure other func init scenarios remain unchanged.

Work Items

[ ] Add --configurationProfile flag to func init.
[ ] Implement supported value: mcp-custom-handler.
[ ] Generate host.json and local.settings.json with correct values.
[ ] Handle existing files gracefully.
[ ] Add tests for new functionality.
[ ] Update documentation.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions