Files
CxIDE/CxSwiftAgent/README.md
T
cx-git-agent c118996746 feat: CxIDE v1 — native macOS SwiftUI IDE with agentic AI assistant
- SwiftUI macOS app with C++17 code analysis engine (ObjC++ bridge)
- Agentic AI loop: LLM plans → tool calls → execution → feedback loop
- 15 agent tools: file ops, terminal, git, xcode build, code intel
- 7 persistent terminal tools with background session management
- Chat sidebar with agent step rendering and auto-apply
- NVIDIA NIM API integration (Llama 3.3 70B default)
- OpenAI tool_calls format with prompt-based fallback
- Code editor with syntax highlighting and multi-tab support
- File tree, console view, terminal view
- Git integration and workspace management
2026-04-21 16:05:52 -05:00

5.1 KiB

CxSwiftAgent — Swift MCP Coding Agent

Native Swift implementation of the CxAI Studio MCP coding agent with 56+ tools. Zero external dependencies — Foundation only, Swift Package Manager.

Architecture

Sources/CxSwiftAgent/
├── main.swift                 Entry point (CLI + server bootstrap)
├── Core/
│   ├── MCPServer.swift        MCP server (JSON-RPC 2.0 over HTTP + stdio)
│   ├── AgentConfig.swift      Configuration loading (env + file)
│   ├── AgentMemory.swift      Actor-based cross-turn context memory
│   └── (reserved)
├── Models/
│   └── MCPTypes.swift         JSON-RPC, MCP protocol types, JSON helpers
└── Tools/
    ├── FileOpsTools.swift      10 tools — file_read/write/patch/search/list/tree/info/delete/move/find
    ├── CodeIntelTools.swift    10 tools — code_complete/explain/review/refactor/fix/document/test/security/symbols/diff_explain
    ├── GitTools.swift           8 tools — git_status/diff/log/commit/branch/blame/stash/show
    ├── ProjectTools.swift       5 tools — project_detect/run/deps/config/create
    ├── TerminalTools.swift      2 tools — terminal_exec/env
    ├── XcodeTools.swift        10 tools — xcode_build/test/analyze/schemes/devices/swift_check/clean/archive/provisioning/swift_format
    ├── DiagnosticsTools.swift   5 tools — diag_workspace/lint/todo/duplicates/complexity
    └── AutoPilotTools.swift     6 tools — autopilot_plan/execute/memory/context/diff/status

Quick Start

Build

cd swift-coding-agent
swift build -c release

Run (HTTP server)

.build/release/cx-swift-agent --port 3001 --workspace /path/to/project

Run (stdio — for VS Code / Xcode Intelligence)

.build/release/cx-swift-agent --stdio

MCP Client Configuration

VS Code — copy config/mcp-vscode.json to your workspace .vscode/mcp.json:

{
    "mcpServers": {
        "cx-swift-agent": {
            "command": "/path/to/cx-swift-agent",
            "args": ["--stdio"],
            "env": {
                "CX_WORKSPACE": "${workspaceFolder}"
            }
        }
    }
}

Xcode — copy config/mcp-xcode.json to your project root.

Tools (56)

Category Tools Count
File Operations file_read, file_write, file_patch, file_search, file_list, file_tree, file_info, file_delete, file_move, file_find 10
Code Intelligence code_complete, code_explain, code_review, code_refactor, code_fix, code_document, code_test, code_security, code_symbols, code_diff_explain 10
Git git_status, git_diff, git_log, git_commit, git_branch, git_blame, git_stash, git_show 8
Project project_detect, project_run, project_deps, project_config, project_create 5
Terminal terminal_exec, terminal_env 2
Xcode xcode_build, xcode_test, xcode_analyze, xcode_schemes, xcode_devices, xcode_swift_check, xcode_clean, xcode_archive, xcode_provisioning, xcode_swift_format 10
Diagnostics diag_workspace, diag_lint, diag_todo, diag_duplicates, diag_complexity 5
AutoPilot autopilot_plan, autopilot_execute, autopilot_memory, autopilot_context, autopilot_diff, autopilot_status 6

MCP Protocol

Implements MCP 2025-03-26:

  • Transport: HTTP (default) or stdio
  • Methods: initialize, tools/list, tools/call, resources/list, resources/read, prompts/list, prompts/get, roots/list, logging/setLevel, ping
  • REST endpoints: GET /health, /ready, /status, /mcp/tools, /metrics; POST /mcp; DELETE /mcp

Configuration

Environment variables (all optional):

Variable Default Description
CX_HOST 0.0.0.0 Server bind address
CX_PORT 3001 Server port
CX_WORKSPACE . Workspace root directory
CX_TRANSPORT http Transport: http or stdio
CX_LOG_LEVEL info Log level: debug, info, warn, error
CX_LLM_ENDPOINT LLM API endpoint (for code intelligence tools)
CX_LLM_MODEL meta/llama-3.1-70b-instruct LLM model name
NVIDIA_API_KEY NVIDIA NIM API key
CX_SANDBOX 0 Enable sandbox mode (blocks writes)
CX_AUTH_TOKEN Bearer token for auth
CX_PROFILE development Config profile
CX_XCODE_PATH /usr/bin/xcodebuild Path to xcodebuild

Also loads cx-agent.conf from workspace root (key=value format).

Security

  • Path traversal protection — all file paths validated against workspace root
  • Dangerous command blocking in terminal_exec
  • Sandbox mode blocks writes, deletes, commits
  • API keys redacted in terminal_env output
  • Auth token support for HTTP endpoints
  • CORS with configurable allowed origins

Requirements

  • Swift 5.9+
  • macOS 14+ or Linux (Ubuntu 22.04+)
  • No external dependencies

Tests

swift test