Skip to content

Conversation

@pamaforce
Copy link
Contributor

@pamaforce pamaforce commented Jan 6, 2026

Summary

This PR introduces a major refactoring of the veFaaS MCP Server, porting core capabilities from vefaas-cli to Python. The new vefaas_cli_sdk module provides:

  • 🚀 Streamlined Deployment: One-command deployment with automatic project detection
  • 💻 Local Development Support: Pull function code, auto-generate config files, and sync changes
  • ⚙️ Unified Configuration: Compatible with vefaas-cli's .vefaas/config.json format

Highlights

🚀 One-Command Deployment

Before (6 tool calls required):

detect_project → create_function → upload_code → release_function → create_vefaas_application → poll_status

After (1 tool call):

deploy_application(project_path="/path/to/app", name="my-app", start_command="...", port=8080)
# Returns: application_id, function_id, access_url, console_url

💻 Local Development Workflow

# 1. Pull existing function code for local development
pull_function_code(function_id="xxx", dest_dir="/path/to/dev")
# → Downloads code, generates vefaas.yaml with function config

# 2. Edit code locally...

# 3. Push changes back (auto-reads config from vefaas.yaml)
update_function(function_id="xxx", project_path="/path/to/dev")
release_function(function_id="xxx")

# Or use one-command deploy with cached config
deploy_application(project_path="/path/to/dev")
# → Auto-reads function_id from .vefaas/config.json

⚙️ Cross-Region Deployment

# Deploy to different region - creates new application
deploy_application(project_path="/path/to/app", name="my-app-sg", region="ap-southeast-1")
# → Ignores cn-beijing config, creates fresh deployment in ap-southeast-1

New Module: vefaas_cli_sdk

A new SDK module ported from vefaas-cli (TypeScript):

File Purpose Lines
detector.py Auto-detect framework, runtime, commands ~670
deploy.py VeFaaSClient, deployment workflow ~1000
config.py Read/write config files ~270

Supported Frameworks

Node.js: Next.js, Nuxt, Vite, VitePress, Rspress, Express, Astro, SvelteKit, Remix, Angular, Gatsby, CRA

Python: FastAPI, Flask, Streamlit, Django

Static: HTML sites, Hugo, MkDocs, Zola, Hexo


Tool Changes

Enhanced Tools

Tool Changes
deploy_application PRIMARY TOOL - Full workflow automation, region-aware config, actionable error messages
detect_project Uses new detector module for accurate framework detection
get_function_detail Returns source_type, better optional field handling
pull_function_code Generates vefaas.yaml for local dev, graceful error handling
update_function Uses .vefaasignore filtering for code packaging

Removed Tools (Merged into deploy_application)

  • create_vefaas_application
  • poll_vefaas_application_status
  • list_vefaas_application_templates
  • get_vefaas_application_template

Key Features

1. Region-Aware Configuration

Config IDs are only used when the stored region matches the target region:

# .vefaas/config.json
{"function": {"id": "xxx", "region": "cn-beijing"}}

# deploy_application(region="cn-shanghai") 
# → Ignores cn-beijing config, creates new deployment

2. Dual Config Format Support

Writes to both formats for compatibility:

  • .vefaas/config.json - vefaas-cli format
  • vefaas.yaml - Legacy MCP format

3. .vefaasignore Support

Package code with gitignore-style patterns:

# Auto-created .vefaasignore
.git/
.venv/
__pycache__/
node_modules/
.vefaas/

4. Actionable Error Messages

{
  "success": false,
  "error": "build_command is required for Node.js project",
  "next_action": "Provide build_command or set skip_build=True"
}

File Changes

File Change
vefaas_cli_sdk/__init__.py 🆕 New
vefaas_cli_sdk/deploy.py 🆕 New (~1000 lines)
vefaas_cli_sdk/detector.py 🆕 New (~670 lines)
vefaas_cli_sdk/config.py 🆕 New (~270 lines)
vefaas_server.py ✏️ Refactored
vefaas_server_test.py ✏️ Updated tests
pyproject.toml ✏️ Added dependencies

New Dependencies

  • pathspec - .vefaasignore pattern matching
  • pyyaml - YAML config file support

Testing

  • Unit tests for vefaas_cli_sdk module
  • Region-aware deployment tests
  • Cross-region deployment scenarios
  • Config file compatibility tests

@CLAassistant
Copy link

CLAassistant commented Jan 6, 2026

CLA assistant check
All committers have signed the CLA.

## Summary

This is a major refactoring of the veFaaS MCP Server to introduce a new
vefaas_cli_sdk module ported from vefaas-cli, providing better project
detection, deployment workflow, and configuration management.

## New Components

### vefaas_cli_sdk module (new)
- **deploy.py**: Core deployment logic
  - VeFaaSClient: Unified API client with error handling
  - Package directory with .vefaasignore support
  - Static site deployment with Caddyfile generation
  - Full deployment workflow (create/update function, build, release, poll status)

- **detector.py**: Project detection module
  - Auto-detect framework (Next.js, Vite, FastAPI, Flask, Streamlit, etc.)
  - Detect runtime, build command, start command, and port
  - Support for Node.js, Python, and static site projects

- **config.py**: Configuration management
  - Read/write .vefaas/config.json (vefaas-cli compatible)
  - Read/write vefaas.yaml (legacy MCP format)
  - Region-aware configuration linking

## Tool Changes

### deploy_application (enhanced)
- Now the PRIMARY deployment tool - one command to deploy
- Handles full workflow: detect → build → package → upload → create/update → release
- Region-aware configuration: only uses cached IDs if region matches
- Explicit build_command validation for non-Python runtimes
- Clear error messages with actionable next_action guidance

### detect_project (enhanced)
- Uses new detector module for accurate framework detection
- Returns comprehensive project configuration

### get_function_detail / pull_function_code (enhanced)
- Better error handling for optional fields
- Returns SourceType for early validation

### Removed tools
- create_vefaas_application (merged into deploy_application)
- poll_vefaas_application_status (handled internally)
- list_vefaas_application_templates (no longer needed)
- get_vefaas_application_template (no longer needed)

## Test Updates
- Added tests for new vefaas_cli_sdk module
- Updated existing tests for refactored tools
- Added region-aware deployment tests

## Dependencies
- Added 'pathspec' for .vefaasignore pattern matching
- Added 'pyyaml' for YAML config file support
@pamaforce pamaforce changed the title feat(vefaas): add vefaas_cli_sdk for improved deployment capabilities feat(vefaas): add vefaas_cli_sdk module for streamlined deployment and local development Jan 8, 2026
@ZhengfengGao ZhengfengGao merged commit 158b8f8 into volcengine:main Jan 8, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants