SuperAPI AI Directory

deploy-website

Frontend & websites

View repository

Updated 10-15 17:33

About this skill

Deploy website

Automatically detect the project type, use background_terminal_create start in the background the corresponding development server, and after confirming successful startup, use the MCP tool request_preview to obtain the preview URL.

Project type detection logic

  1. Node.js Web project

    • Look for in the workspace root directory package.json
    • Check whether it contains dev or start script
    • Execute npm run dev(if there is no dev , then execute npm start)
  2. Static website

    • Look for in the workspace .html files (especially index.html)
    • Execute python3 -m http.server 8000 to serve static files
  3. Other types of websites

    Detect the type based on the project's characteristic files and use the corresponding server:

  • PHP project - Look for .php file or composer.json
    • Execute php -S localhost:8000
    • If public/index.phpexists, then from the public directory serve
  • Python project
    • Django - Look for manage.py and settings.py
      • Execute python manage.py runserver 8000
    • Flask - Look for app.py or wsgi.py
      • Execute python app.py or flask run --port=8000
    • Gunicorn/uWSGI - Look for gunicorn.conf.py or uwsgi.ini
      • Execute gunicorn -b 0.0.0.0:8000 app:app(adjust according to the actual module name)
    • Generic Python - Look for requirements.txt or pyproject.toml
      • Execute python -m http.server 8000
  • Go project - Look for go.mod
    • Execute go run main.go or go run .
  • Ruby/Rails - Look for containing rails of Gemfile
    • Execute rails server -p 8000 or bundle exec rails server -p 8000
  • Java/Spring Boot - Look for pom.xml(Maven) or build.gradle(Gradle)
    • Execute mvn spring-boot:run or ./gradlew bootRun
  • Rust/Axum/Actix - Look for Cargo.toml
    • Execute cargo run
  • Detection based on README - If none of the above methods match:
    • Search README files (README.md、README.rst、README.txt、doc/README.md)
    • Look for containing run、start、serve、dev、preview commands with keywords such as
    • Extract and execute the corresponding command

Workflow

1. Check whether a server process already exists

Before starting a new server, perform the following checks:

  • Call background_terminal_list to check whether there is already a running background terminal
  • Check whether any process is already listening on a port:
ss -tlnp 2>/dev/null || netstat -tlnp 2>/dev/null || lsof -iTCP -sTCP:LISTEN -P -n

If an existing server process is detected:

  • Extract the port number from the output
  • Skip the startup step and directly use that port to call request_preview
  • Notify the user that an existing server was detected

2. Consult the project documentation to determine the startup command (highest priority)

Before using the default detection logic,you must first consult the project documentation, to confirm whether the project has a clearly specified startup method. Read the documentation in the following order:

  1. .monkeycode/MEMORY.md - Project memory file, which may contain previously recorded startup methods
  2. README.md - Project documentation, usually containing the development server startup command
  3. AGENTS.md - Agent instruction file, which may contain startup guidance for the AI assistant

Search target: Search the above documents for content related to starting a Web service, for example:

  • An explicit startup command (such as npm run dev、make serve、docker compose up , etc.)
  • Prerequisite steps before startup (such as environment variable settings, configuration file generation, etc.)
  • The specified port number or special parameters

Decision logic:

  • If the document containsexplicit startup instructions, then follow the document's description and use the command specified in the document to start the server
  • This startup command needs to match the identified project type (such as development language)
  • Clearly inform the user: which document was followed for the method of starting the Web service (for example: "Start the development server according to the instructions in README.md")
  • If there is no relevant description in the document, or the description is unclear, fall back to the default detection logic below

3. Detect the project type and use background_terminal_create to start the server

Execute the default detection logic of this step only when no existing server is detected and no explicit startup instructions are found in the project documentation.

Important: You must use the MCP tool background_terminal_create to start the server. This tool runs commands in a background terminal, does not block the current session, and provides output log tracking.

Call background_terminal_create according to the project type to execute the corresponding command:

  • Node.js project(there is package.json):

    • First run npm install in the foreground to ensure dependencies are installed
    • Then use background_terminal_create to execute npm run dev(or npm start)
  • PHP project(there is composer.json or .php file):

    • Use background_terminal_create to execute php -S localhost:8000
    • If there is public/index.php, then execute php -S localhost:8000 -t public
  • Python/Django(there is manage.py):

    • Use background_terminal_create to execute python manage.py runserver 8000
  • Python/Flask(there is app.py or wsgi.py):

    • Use background_terminal_create to execute flask run --port=8000 or python app.py
  • Python/Gunicorn(there is gunicorn.conf.py or uwsgi.ini):

    • Use background_terminal_create to execute gunicorn -b 0.0.0.0:8000 app:app
  • Python general(there is requirements.txt or pyproject.toml):

    • Use background_terminal_create to execute python -m http.server 8000
  • Go project(there is go.mod):

    • Use background_terminal_create to execute go run . or go run main.go
  • Ruby/Rails(Gemfile contains rails):

    • Use background_terminal_create to execute bundle exec rails server -p 8000
  • Java/Spring Boot(there is pom.xml or build.gradle):

    • Use background_terminal_create to execute ./mvnw spring-boot:run or ./gradlew bootRun
  • Rust project(there is Cargo.toml):

    • Use background_terminal_create to execute cargo run
  • Static HTML file(there is index.html or other .html file):

    • Use background_terminal_create to execute python3 -m http.server 8000
  • Detect based on README(when none of the above match):

    • Extract the startup command from the README file, use background_terminal_create to execute

4. Read the output logs to confirm the server started successfully

background_terminal_create The returned result contains the child process ID (PID); record this PID for subsequent management.

Then confirm the server has started successfully through the following steps:

# 第 1 步:调用 background_terminal_output_path 获取日志文件路径
# 第 2 步:使用 Read 工具读取日志文件
# 第 3 步:查找启动成功的标志,例如:
#   - "Listening on port ..."
#   - "Server running at ..."
#   - "ready in ... ms"
#   - "Local: http://localhost:..."
# 第 4 步:若启动失败,读取日志中的错误信息并排查问题

If the logs show the server has not finished starting, wait a few seconds and re-read the log file, repeating this process until you confirm the server is running or detect an error.

5. Get the preview address

Call the MCP tool request_preview, pass in the port number the server is listening on, and get the preview URL.

6. Check the preview connection status

Call request_preview to get access_url , you must check whether the preview connection is normal. Use curl to request the preview service's health check endpoint:

curl -s --max-time 10 "$ACCESS_URL/.well-known/mcai-preview-connect-status-detect" | head -n10

Detection logic:

  1. Ignore curl's exit code and HTTP response code,only checkwhether the response body contains <meta name="mcai-preview-error"
  2. Because the requested mcai-preview-connect-status-detect is a dummy address, this file definitely does not exist on the backend; this request is only to determine whether the front-end proxy returns an error. So as long as the responsedoes not containthe above meta, it means the preview connection is normal. There is no need to pay attention to other errors in the response; please skip the troubleshooting steps below and continue to show the preview address to the user
  3. Ifcontains mcai-preview-error this meta, it means the cloud preview service cannot access the local site. You need to extract the error information from the meta tag attributes:
    • code — error status code
    • content — error reason description
    • data-request-id — request ID

meta tag format:

<meta name="mcai-preview-error" code="530" content="开发环境端口 9091 连接失败,请检查 Web 站点进程是否已经退出,以及该端口是否有在监听。" data-request-id="RL-xxxxxxxx"/>

Exception troubleshooting process:

Based on the extracted code (error code) and content (exception reason),

  • Check the backend terminal logs and troubleshoot application code errors
  • Check whether the server process is still running
  • Try to fix and redeploy

7. Show the preview address to the user

  • Output a clickable hyperlink pointing to request_preview the preview address returned
  • Inform the user of the backend terminal ID for subsequent management

8. Handle IP whitelist issues

  • If the user reports being unable to access because their IP is not whitelisted, ask the user to provide the IP address shown on the rejection page
  • Call the MCP tool again request_preview, use additional_ip_whitelist the field to add the user's IP
  • additional_ip_whitelist The field accepts multiple IPv4 addresses, separated by commas (for example "192.168.1.100,10.0.0.50")

Process management

The server must be started using a backend terminal

It is strictly prohibited to use the exec tool to directly start the server process, it must be started using a backend terminal.

View backend terminals

Use background_terminal_list to view all running backend terminals and their statuses.

View server output

Use background_terminal_output_path to get the log file path of the backend terminal, then read the log file to view the server output, errors, or running status.

Stop the server

When the user requests to stop the server, use background_terminal_kill and pass in the terminal ID to stop it.

Strictly prohibitedto use pkill or killall Stop the server by using the process name (for example, pkill node、killall python), which may cause:

  • Killing processes manually started by the user by mistake
  • Killing other unrelated development servers by mistake
  • Killing system processes with the same name by mistake

Always use background_terminal_kill to stop servers started by this skill.

Notes

  • You must use background_terminal_create to start the server to ensure it does not block the current session
  • After starting, you must use background_terminal_output_path to get the log path and read the logs, confirm the server is running, and then get the preview address
  • Before starting, be sure to check whether a server process already exists to avoid port conflicts
  • The default port for the static server is 8000
  • The port for a Node.js project depends on the project configuration
  • If there is a port conflict, you can dynamically change the port number
  • Use background_terminal_list to track the running terminal, and use background_terminal_kill to stop the terminal
  • It is strictly prohibited to use pkill or killall to stop the server; you must use background_terminal_kill plus the terminal ID
  • Before running the server, ensure dependencies are installed:
    • Node.js:npm install
    • Python:pip install -r requirements.txt(if present)
    • PHP:composer install(if present composer.json)
    • Ruby/Rails:bundle install(if present Gemfile)
    • Go:go mod download(go run is handled automatically)
    • Java: Maven/Gradle wrapper handles dependencies automatically
    • Rust:cargo fetch(cargo run is handled automatically)