abelcha/mcpx
3.1
If you are the rightful owner of mcpx and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
The Swift MCP Server, named `mcpx`, is a single binary application designed to handle filesystem, git, and HTTP fetch operations using the Model Context Protocol (MCP).
Tools
3
Resources
0
Prompts
0
Swift MCP Server
Project Goal
Reimplement the 3 core MCP servers (filesystem, git, fetch) as a single Swift binary called mcpx.
Why Swift?
- Single binary deployment (no Node.js dependency)
- Native macOS performance
- Clean, modern syntax
- Excellent Foundation library for filesystem/networking
- First-class MCP Swift SDK available
Architecture Overview
Single Binary, Multiple Tools
mcpx
├── fs (filesystem operations)
├── git (git operations)
└── fetch (HTTP requests)
Command Structure
mcpx --allow-dir /path/to/project
# Exposes all three tool sets via MCP protocol
Core Requirements
1. Filesystem Server (fs)
Tools to implement:
read_file- Read file contents with UTF-8 encodingwrite_file- Create/overwrite fileslist_directory- List directory contents with [FILE]/[DIR] prefixescreate_directory- Create directories recursivelymove_file- Move/rename files and directoriessearch_files- Recursive file search with pattern matchingget_file_info- File metadata (size, dates, permissions)
Key APIs:
FileManager.defaultfor directory operationsString(contentsOf:)andData.write(to:)for file I/OFileManager.contentsOfDirectory(atPath:)for listings
2. Git Server (git)
Tools to implement:
git_status- Show working directory statusgit_add- Stage filesgit_commit- Create commitsgit_push- Push to remotegit_pull- Pull from remotegit_log- Show commit historygit_diff- Show file differencesgit_branch- Branch operations
Implementation approach:
- Use
Processto execute git commands - Parse stdout/stderr for structured responses
- Handle git credential management
3. Fetch Server (fetch)
Tools to implement:
http_get- GET requests with headershttp_post- POST requests with body/headershttp_put- PUT requestshttp_delete- DELETE requests
Key APIs:
URLSessionfor HTTP requestsJSONSerializationfor JSON handling- Proper error handling for network failures
Project Structure
Sources/
├── SwiftMCP/
│ ├── main.swift # Entry point
│ ├── MCPServer.swift # MCP protocol handling
│ ├── FilesystemTools.swift
│ ├── GitTools.swift
│ └── FetchTools.swift
└── Package.swift
Dependencies
// Package.swift
dependencies: [
.package(url: "https://github.com/modelcontextprotocol/swift-sdk", from: "1.0.0")
]
Security Requirements
- Path validation - Only allow operations within specified directories
- Git safety - Validate git commands to prevent injection
- HTTP limits - Reasonable timeouts and request size limits
- Error handling - Never expose internal system paths in errors
MCP Protocol Integration
- Use the official Swift MCP SDK
- Implement
ListToolsRequestSchemahandler - Implement
CallToolRequestSchemahandler - Follow MCP tool schema patterns from Node.js versions
Success Criteria
- Drop-in replacement - Same MCP tool interface as Node.js versions
- Single binary - No runtime dependencies
- Better performance - Faster than Node.js equivalents
- Clean error messages - User-friendly error handling
- Cross-platform - Works on macOS and Linux
Implementation Order
- Start with filesystem - Core functionality, easiest to test
- Add fetch - HTTP operations, good for testing network handling
- Finish with git - Most complex due to subprocess management
Testing Strategy
- Test against existing MCP clients (Claude Desktop)
- Compare output format with Node.js versions
- Test edge cases: large files, network failures, git errors
- Verify security boundaries work correctly
Key Differences from Node.js Version
- No async/await ceremony - Use Swift's structured concurrency
- Native error types - Proper Swift error handling vs JavaScript exceptions
- Type safety - Compile-time guarantees vs runtime schema validation
- Resource management - Automatic memory management vs manual cleanup