SwiftMCP

v1.0.0Developer Toolsstable

Swift MCP SDK — Model Context Protocol client + server

swiftmcpmcpai-integration
Share:
154
Stars
0
Downloads
0
Weekly
0/5

What is SwiftMCP?

SwiftMCP is a Model Context Protocol (MCP) server that allows AI assistants like Claude, Cursor, and VS Code to swift mcp sdk — model context protocol client + server

Swift MCP SDK — Model Context Protocol client + server

This server falls under the Developer Tools category on MCPgee, the world's largest MCP server directory with 33,000+ servers.

Features

  • Swift MCP SDK — Model Context Protocol client + server

Use Cases

Swift MCP SDK — Model Context Protocol client + server
Cocoanetics

Maintainer

LicenseBSD-2-Clause
Languageswift
Versionv1.0.0
UpdatedMay 21, 2026
Statushealthy
Maintenanceactive

Works with

ClaudeOpenAIwindowsmacoslinux

Installation

Manual Installation

npx swiftmcp

Configuration

Configuration Details

Config File

claude_desktop_config.json

Performance

Response Metrics

Response Time< 200ms
ThroughputMedium

Resource Usage

Memory UsageLow
CPU UsageLow

How to Set Up and Use SwiftMCP

SwiftMCP is a native Swift SDK that implements both the server and client sides of the Model Context Protocol, enabling Apple-platform developers to build MCP-enabled tools and AI integrations using idiomatic Swift. It provides macro-based annotations (@MCPTool, @MCPResource, @MCPPrompt) so developers can expose Swift functions as MCP tools with minimal boilerplate, and supports HTTP/SSE, TCP, and stdio transports. It is aimed at iOS, macOS, and server-side Swift developers who want to integrate AI assistant capabilities into their applications or create custom MCP servers in Swift.

Prerequisites

  • Swift 6.1 or newer (Swift toolchain from swift.org or Xcode 16+)
  • Swift Package Manager (included with Swift)
  • For server transport: NIO-compatible networking (included via swift-nio dependency)
  • For OAuth: a configured OAuth provider with issuer URL and credentials
1

Add SwiftMCP to your Swift package

Add the SwiftMCP dependency to your Package.swift file. Use the 'main' branch for the latest features or pin to a specific tag for stability.

// Package.swift
.package(url: "https://github.com/Cocoanetics/SwiftMCP.git", branch: "main")
2

Add the target dependency

Include SwiftMCP in your target's dependencies list inside Package.swift.

.target(
    name: "MyServer",
    dependencies: [
        .product(name: "SwiftMCP", package: "SwiftMCP")
    ]
)
3

Define your MCP server with macros

Create a class annotated with @MCPServer and mark each function you want to expose with @MCPTool. SwiftMCP generates all the protocol scaffolding automatically.

import SwiftMCP

@MCPServer
class MyServer {
    @MCPTool
    func greet(name: String) -> String {
        return "Hello, \(name)!"
    }

    @MCPTool
    func add(a: Int, b: Int) -> Int {
        return a + b
    }
}
4

Start the server on a transport

Instantiate your server and attach a transport. Use stdio for MCP client integration (Claude Desktop), HTTP/SSE for web-accessible endpoints, or TCP for direct connections.

// stdio (for Claude Desktop / Claude Code integration)
let server = MyServer()
let transport = StdioTransport(server: server)
try transport.run()

// HTTP/SSE
let httpTransport = HTTPSSETransport(server: server, port: 8080)
try httpTransport.run()
5

Configure your MCP client to connect

For Claude Desktop, build the server executable and point the MCP config at it. For HTTP/SSE mode, point at the running server's URL.

{
  "mcpServers": {
    "my-swift-server": {
      "command": "/path/to/MyServer",
      "args": ["stdio"]
    }
  }
}

SwiftMCP Examples

Client configuration

Claude Desktop configuration for a SwiftMCP server binary running in stdio mode.

{
  "mcpServers": {
    "my-swift-mcp-server": {
      "command": "/Users/you/.build/release/MyServer",
      "args": ["stdio"]
    }
  }
}

Prompts to try

Once a SwiftMCP server with custom tools is running, you can invoke those tools through natural language.

- "Call the greet tool with the name 'Alice'"
- "Use the add tool to calculate 42 + 58"
- "List all available tools exposed by the Swift server"
- "Fetch the resource at uri 'file:///Users/me/docs/readme.md' from the server"
- "Run the 'summarize' prompt with the provided text"

Troubleshooting SwiftMCP

Build fails with 'requires Swift tools version 6.1'

Update your Package.swift swift-tools-version header to 6.1 and install Swift 6.1 or newer from swift.org or by upgrading Xcode to version 16+.

Server trait causes linker errors on Windows

The Server trait pulls in swift-nio and swift-certificates which have limited Windows support. Disable the Server trait in Package.swift traits configuration and use only the Client or stdio transport on Windows.

Claude Desktop shows the server as disconnected

Ensure the built binary path in the config is absolute and the binary has execute permissions (`chmod +x /path/to/MyServer`). Test the binary directly in a terminal with the 'stdio' argument to confirm it starts without errors.

Frequently Asked Questions about SwiftMCP

What is SwiftMCP?

SwiftMCP is a Model Context Protocol (MCP) server that swift mcp sdk — model context protocol client + server It connects AI assistants to external tools and data sources through a standardized interface.

How do I install SwiftMCP?

Follow the installation instructions on the SwiftMCP GitHub repository. Clone the repo, install dependencies, and add the server config to your AI client.

Which AI clients work with SwiftMCP?

SwiftMCP works with all major MCP-compatible AI clients including Claude Desktop, Claude Code, Cursor, VS Code (GitHub Copilot), Windsurf, and Cline.

Is SwiftMCP free to use?

Yes, SwiftMCP is open source and available under the BSD-2-Clause license. You can use it freely in both personal and commercial projects.

Browse More Developer Tools MCP Servers

Explore all developer tools servers available in the MCPgee directory. Each server includes setup guides for Claude, Cursor, and VS Code.

Quick Config Preview

{ "mcpServers": { "swiftmcp": { "command": "npx", "args": ["-y", "swiftmcp"] } } }

Add this to your claude_desktop_config.json or .cursor/mcp.json

Read the full setup guide →

Ready to use SwiftMCP?

Browse our complete directory of 33,000+ MCP servers, read setup guides for your editor, and start building with the Model Context Protocol.

33,000+ ServersFree & Open SourceStep-by-Step Guides