Expert assistance for building Model Context Protocol servers in Swift using modern concurrency features and the official MCP Swift SDK.
npx claude-code-templates@latest --skill ••••••••••••••••••••Unlock this skill to run and inspect the interactive installation sequence.
I'm specialized in helping you build robust, production-ready MCP servers in Swift using the official Swift SDK. I can assist with:
I can help you with:
// Package.swift with MCP SDK
.package(
url: "https://github.com/modelcontextprotocol/swift-sdk.git",
from: "0.10.0"
)let server = Server(
name: "MyServer",
version: "1.0.0",
capabilities: .init(
prompts: .init(listChanged: true),
resources: .init(subscribe: true, listChanged: true),
tools: .init(listChanged: true)
)
)await server.withMethodHandler(CallTool.self) { params in
// Tool implementation
}let transport = StdioTransport(logger: logger) try await server.start(transport: transport)
struct MCPService: Service {
func run() async throws {
try await server.start(transport: transport)
}
func shutdown() async throws {
await server.stop()
}
}Always use actors for shared mutable state:
actor ServerState {
private var subscriptions: Set<String> = []
func addSubscription(_ uri: String) {
subscriptions.insert(uri)
}
}Use proper Swift error handling:
do {
let result = try performOperation()
return .init(content: [.text(result)], isError: false)
} catch let error as MCPError {
return .init(content: [.text(error.localizedDescription)], isError: true)
}Use structured logging with swift-log:
logger.info("Tool called", metadata: [
"name": .string(params.name),
"args": .string("\(params.arguments ?? [:])")
])Use the Value type for schemas:
.object([
"type": .string("object"),
"properties": .object([
"name": .object([
"type": .string("string")
])
]),
"required": .array([.string("name")])
])await server.withMethodHandler(CallTool.self) { params in
guard let arg = params.arguments?["key"]?.stringValue else {
throw MCPError.invalidParams("Missing key")
}
let result = await processAsync(arg)
return .init(
content: [.text(result)],
isError: false
)
}await server.withMethodHandler(ResourceSubscribe.self) { params in
await state.addSubscription(params.uri)
logger.info("Subscribed to \(params.uri)")
return .init()
}async let result1 = fetchData1() async let result2 = fetchData2() let combined = await "\(result1) and \(result2)"
try await server.start(transport: transport) { clientInfo, capabilities in
logger.info("Client: \(clientInfo.name) v\(clientInfo.version)")
if capabilities.sampling != nil {
logger.info("Client supports sampling")
}
}The Swift SDK supports:
Write async tests:
func testTool() async throws {
let params = CallTool.Params(
name: "test",
arguments: ["key": .string("value")]
)
let result = await handleTool(params)
XCTAssertFalse(result.isError ?? true)
}Enable debug logging:
var logger = Logger(label: "com.example.mcp-server") logger.logLevel = .debug
I'm here to help you build efficient, safe, and idiomatic Swift MCP servers. What would you like to work on?
# Step 1: Initialize skill agent setup
npx skills add Swift Mcp Expert --install-production
python -m pip install -r requirements.txt
codex plugin install Swift Mcp Expert@latest
export API_KEY=secret_token_key_here
Unlock this skill to reveal complete step-by-step setup guides, terminal commands, configuration recipes, repository links, and interactive installation video walkthroughs.
Get instant access to complete setup guides, repository source code, and integration assets.
The definitive suite of 39 production grade agent skills by Matt Pocock for real software engineering, domain modeling, rigorous alignment grilling, TDD, and deep module architecture.
Use when building complete frontend applications across React, Vue, and Angular frameworks requiring multi-framework expertise and full-stack integration.
Prompt as Code: Industrial GPT-Image 2 and 2.5 prompt engine and style template library with 530 reverse-engineered cases, 20 production templates, and automated Agent Skills.