flipped-aurora/gin-vue-admin · warning

当前 MCP 服务不是由页面启动的,无法自动停用

Error message

当前 MCP 服务不是由页面启动的,无法自动停用

What it means

StopManagedStandalone stops the MCP standalone service only if the backend itself started it (verified via the managed-process meta file). When meta cannot be read (service not page-managed) but the endpoint IS reachable, it returns this error to tell the caller the running instance belongs to something else (e.g. manually launched `go run`) and cannot be auto-terminated. If the service is unreachable and unmanaged, it returns the status with no error.

Source

Thrown at server/mcp/standalone_manager.go:205

		LogPath:    logPath,
		ConfigPath: configPath,
		WorkDir:    workDir,
		Command:    commandPath,
		Args:       append([]string{}, commandArgs...),
	}
	if err := writeManagedProcessMeta(meta); err != nil {
		return GetManagedStandaloneStatus(context.Background()), err
	}

	return waitForManagedProcess(ctx, meta)
}

func StopManagedStandalone(ctx context.Context) (ManagedStandaloneStatus, error) {
	meta, err := readManagedProcessMeta()
	if err != nil {
		status := GetManagedStandaloneStatus(ctx)
		if status.Reachable {
			return status, errors.New("当前 MCP 服务不是由页面启动的,无法自动停用")
		}
		return status, nil
	}

	if meta.PID > 0 && processExists(meta.PID) {
		if err := terminateProcess(meta.PID); err != nil {
			return GetManagedStandaloneStatus(context.Background()), fmt.Errorf("停用 MCP 独立服务失败: %w", err)
		}
	}

	deadline := time.NewTimer(mcpStopWaitTimeout)
	ticker := time.NewTicker(200 * time.Millisecond)
	defer deadline.Stop()
	defer ticker.Stop()

	for {
		select {
		case <-ctx.Done():

View on GitHub (pinned to 3136500ef3)

Solutions

  1. Stop the process manually: find the PID listening on the MCP port and kill it (e.g. lsof -i :PORT then kill PID)
  2. Restart the service from the admin page so it becomes page-managed, then stop it from the page
  3. Check the MCP runtime meta file (mcp runtime dir) is intact; if it was deleted, the running process is orphaned and must be killed manually
  4. Verify GetManagedStandaloneStatus in the UI to confirm who owns the running process before stopping

Example fix

// manually stop an orphaned MCP process
lsof -i :8888    # find PID bound to the MCP port
kill <PID>       # then manage lifecycle from the page
Defensive patterns

Strategy: fallback

Try / catch

status, err := mcp.StopManagedStandalone(ctx)
if err != nil {
    log.Printf("service is externally managed: %v; stop it manually", err)
    // fall back: locate PID by port and terminate by hand
}

Prevention

When it happens

Trigger: Clicking stop/deactivate for the MCP standalone service in the page while the service was started manually from a terminal, by another tool, or the managed-process meta file was deleted/corrupted while the process still runs.

Common situations: Developer started the MCP server via `go run ./cmd/mcp` or a compiled binary by hand, then tries to manage it from the admin UI; stale or wiped runtime meta directory after reinstall/clean while an orphan process keeps listening.

Related errors


AI-assisted analysis of flipped-aurora/gin-vue-admin@3136500ef3 (2026-08-31). Data as JSON: /api/errors/536a0db082ae3423. Report an issue: GitHub.