About SwiftMCP
SwiftMCP is an MCP server published by koaWood in the Developer Tools category: 100% swift implementation of MCP client & server - in 3 transports.
The repository has 6 stars and 1 forks, with the last commit 8 months ago. Six months or more without a commit doesn't mean the server is broken, but check the open issues before depending on it in production.
Install
git clone https://github.com/koaWood/swiftMCPThis server has no ConduID identity, so agent calls to it are not receipted. Pin the version you install and review the source before granting it credentials.
Ask AI
Ask AI about SwiftMCP
Powered by Claude · Grounded in docs
Security checks
Static checks derived from the repository 7 days ago. Heuristics on the source, not an audit.
- ✓README presentThe repository ships documentation.
- ✓License declaredUsable under a stated license.
- !Tests presentNo tests found. Behaviour changes may go unnoticed between versions.
- !Dependencies pinnedNo lockfile. Installs can pull different code over time.
2 checks have not been run yet.
README
swiftMCP
A comprehensive Swift implementation of the Model Context Protocol (MCP), demonstrating multiple transport mechanisms for client-server communication.
Overview
swiftMCP provides complete, working examples of MCP clients and servers in Swift, showcasing three different transport implementations:
- stdio - Standard input/output transport for process-based communication
- httpPOST - HTTP POST-based transport using Hummingbird web framework
- httpGET - HTTP GET with Server-Sent Events (SSE) for streaming responses
Each example includes both client and server implementations, making it easy to understand how MCP works across different transport layers.
The examples are designed to build on each other progressively. Start with 1_stdio to learn the core MCP concepts using the simplest transport mechanism. Once you understand the fundamentals, move to 2_httpPOST to see how the same protocol works over HTTP with request-response patterns. Finally, explore 3_httpGET to understand real-time streaming responses with Server-Sent Events. This learning path takes you from basic process communication to a more sophisticated web service architecture.
What is MCP?
The Model Context Protocol is a standardized protocol for communication between AI assistants and external tools/services. It enables:
- Tool Discovery - Dynamically list available capabilities
- Tool Invocation - Execute tools with structured parameters
- Resource Access - Read and manipulate external resources
- Prompts - Templated interactions for common tasks
Project Structure
swiftMCP/
├── 1_stdio/ # Standard I/O transport example
│ ├── client/ # Swift client using subprocess pipes
│ └── server/ # Swift server using stdin/stdout
├── 2_httpPOST/ # HTTP POST transport example
│ ├── client/ # Swift HTTP client
│ ├── server/ # Hummingbird-based HTTP server
│ └── web-client.html # Browser-based client
├── 3_httpGET/ # HTTP GET + SSE transport example
│ ├── client/ # Swift HTTP client with streaming
│ ├── server/ # Hummingbird server with SSE support
│ └── web-client.html # Browser client with event streaming
└── common/ # Shared code
├── tools/ # Reusable tool implementations
└── util/ # Common utilities (JSON-RPC, debug, etc.)
Requirements
- macOS 14.0 or later
- Swift 6.1 or later
- Xcode 16.0 or later (for development)
Getting Started
1. stdio Transport Example
The simplest example using standard input/output:
cd 1_stdio/client
swift run
This will:
- Start the server as a subprocess
- Connect to it via stdin/stdout pipes
- List available tools
- Call the tools
- Display results
2. httpPOST Transport Example
HTTP-based communication:
# Terminal 1 - Start the server
cd 2_httpPOST/server
swift run
# Terminal 2 - Run the client
cd 2_httpPOST/client
swift run
Or open 2_httpPOST/web-client.html in a browser to use the web interface.
3. httpGET Transport Example
Streaming HTTP with Server-Sent Events:
# Terminal 1 - Start the server
cd 3_httpGET/server
swift run
# Terminal 2 - Run the client
cd 3_httpGET/client
swift run
Or open 3_httpGET/web-client.html in a browser for the streaming web interface.
Features
Transport Implementations
- StdioTransport - Efficient process-to-process communication
- HTTPTransport - RESTful API communication with JSON-RPC
- SSETransport - Real-time streaming updates
Common Utilities
- JSON-RPC 2.0 - Full implementation with request/response handling
- Tool Framework - Extensible tool registration and invocation
- Health Checks - Server health monitoring
- Debug Utilities - Comprehensive logging system
- Notifications - Event notification support
Example Tools
- Tool_1 - System LINUX command (Swift version check)
- Tool_2 - Custom method handler demonstration
- Tool_3 - Streaming data demonstration
Architecture
Each example follows the same pattern:
-
Server Setup
- Initialize MCP server with capabilities
- Register tool handlers
- Start transport listener
-
Client Connection
- Create MCP client
- Connect via chosen transport
- Initialize handshake
-
Tool Operations
- List available tools
- Call tools with parameters
- Handle responses
Dependencies
This project uses the official MCP Swift SDK:
.package(url: "https://github.com/modelcontextprotocol/swift-sdk.git", from: "0.10.2")
HTTP examples also use:
.package(url: "https://github.com/hummingbird-project/hummingbird.git", from: "2.0.0")
Development
Building
# Build a specific example
cd 1_stdio/client
swift build
# Build in release mode
swift build -c release
Use Cases
- AI Assistant Integration - Connect AI models to external tools
- Development Tools - Build IDE plugins and development assistants
- Automation - Create automated workflows with tool orchestration
- Learning - Understand MCP protocol implementation in Swift
Contributing
Contributions are welcome! Please feel free to submit issues or pull requests.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Resources
Acknowledgments
Built with the official Model Context Protocol Swift SDK from the Model Context Protocol organization.
Repository: github.com/koawood/swiftMCP
README fetched from the repository 7 days ago. The original is authoritative.