.claude/skills/swift-fast-mcp/SKILL.md
Generate a complete MCP server project in Swift using the FastMCP library. Use when asked to create a Swift MCP server, build an MCP tool server, or scaffold a Model Context Protocol project in Swift.
npx skillsauth add mehmetbaykar/swift-fast-mcp swift-fast-mcpInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
FastMCP is a high-level Swift library for building Model Context Protocol servers. It wraps the official MCP Swift SDK with a fluent builder API, protocol-based tools/resources/prompts, automatic JSON Schema generation via @Schemable, structured tool output via MCPStructuredTool, and lifecycle management.
$ARGUMENTS[0] = project name (e.g., MyServer). Default: MCPServer$ARGUMENTS[1] = comma-separated features: tools, resources, prompts. Default: all three.$ARGUMENTS[0]/
├── Package.swift
├── Sources/
│ ├── $ARGUMENTS[0]Lib/
│ │ ├── Tools/
│ │ │ └── ExampleTool.swift
│ │ ├── Resources/
│ │ │ └── ExampleResource.swift
│ │ └── Prompts/
│ │ └── ExamplePrompt.swift
│ └── $ARGUMENTS[0]/
│ └── main.swift
├── Tests/
│ └── $ARGUMENTS[0]Tests/
│ └── ServerTests.swift
└── README.md
Only include subdirectories for requested features (e.g., omit Prompts/ if not in $ARGUMENTS[1]).
// swift-tools-version: 6.2
import PackageDescription
let package = Package(
name: "$ARGUMENTS[0]",
platforms: [.macOS(.v14)],
dependencies: [
.package(url: "https://github.com/mehmetbaykar/swift-fast-mcp.git", from: "2.2.0"),
],
targets: [
.target(
name: "$ARGUMENTS[0]Lib",
dependencies: [
.product(name: "FastMCP", package: "swift-fast-mcp"),
]
),
.executableTarget(
name: "$ARGUMENTS[0]",
dependencies: ["$ARGUMENTS[0]Lib"]
),
.testTarget(
name: "$ARGUMENTS[0]Tests",
dependencies: ["$ARGUMENTS[0]Lib"]
),
]
)
Key points:
swift-fast-mcp — it transitively provides MCP, MCPToolkit, Logging, UnixSignalsimport FastMCP
import $ARGUMENTS[0]Lib
import Logging
@main
struct $ARGUMENTS[0] {
static func main() async throws {
var logger = Logger(label: "$ARGUMENTS[0]")
logger.logLevel = .info
try await FastMCP.builder()
.name("$ARGUMENTS[0]")
.version("1.0.0")
.addTools([
// Add tool instances here
])
.addResources([
// Add resource instances here
])
.addPrompts([
// Add prompt instances here
])
.enableCompletions()
.enableLogging()
.transport(.stdio)
.logger(logger)
.shutdownSignals([.sigterm, .sigint])
.onStart {
print("Server started")
}
.onShutdown {
print("Server shutting down")
}
.run()
}
}
import FastMCP re-exports: MCP, MCPToolkit, Logging, UnixSignals. No other imports needed for tool/resource/prompt files.
Attach a FastMCPServerHandle to add or remove tools/resources/prompts at runtime. Connected clients are automatically notified via MCP listChanged notifications.
import FastMCP
let handle = FastMCPServerHandle()
Task {
try await FastMCP.builder()
.name("DynamicServer")
.addTools([WeatherTool()])
.serverHandle(handle)
.run()
}
// Later, from another task:
await handle.addTool(MathTool())
await handle.removeTool(named: "get_weather")
await handle.addResource(ConfigResource())
await handle.removeResource(uri: "config://app/settings")
await handle.addPrompt(GreetingPrompt())
await handle.removePrompt(named: "greeting")
When a handle is attached:
listChanged: true is advertised in server capabilities for tools, resources, and promptsname. First registration wins.uri. First registration wins.name. First registration wins.import FastMCP
public struct GreetTool: MCPTool {
public let name = "greet"
public let description: String? = "Generate a greeting"
public var annotations: Tool.Annotations {
Tool.Annotations(readOnlyHint: true, idempotentHint: true)
}
public init() {}
@Schemable
public struct Parameters: Sendable {
public let name: String
public init(name: String) { self.name = name }
}
public func call(with arguments: Parameters) async throws(ToolError) -> Content {
[ToolContentItem(text: "Hello, \(arguments.name)!")]
}
}
import FastMCP
public struct SearchTool: MCPStructuredTool {
public typealias Output = SearchResult
public let name = "search"
public let description: String? = "Return structured search results"
public init() {}
@Schemable
public struct Parameters: Sendable {
public let query: String
public init(query: String) { self.query = query }
}
@Schemable
public struct SearchResult: Codable, Sendable {
public let summary: String
public let resultCount: Int
public init(summary: String, resultCount: Int) {
self.summary = summary
self.resultCount = resultCount
}
}
public func callStructured(with arguments: Parameters) async throws(ToolError)
-> StructuredToolResult<SearchResult>
{
let summary = "Found 2 results for \(arguments.query)"
return StructuredToolResult(
structuredContent: SearchResult(summary: summary, resultCount: 2)
) {
ToolContentItem(text: summary)
}
}
}
Use MCPStructuredTool when the client needs typed data in structuredContent and an
outputSchema published through tools/list. Plain MCPTool is still the right choice for
content-only tools.
import FastMCP
public struct ConfigResource: MCPResource {
public let uri = "config://app/settings"
public let name = "App Settings"
public let description: String? = "Application configuration"
public let mimeType: String? = "application/json"
public init() {}
public var content: Content {
"""
{"version": "1.0.0", "environment": "development"}
"""
}
}
import FastMCP
public struct GreetingPrompt: MCPPrompt {
public let name = "greeting"
public let description: String? = "A friendly greeting"
public init() {}
@Schemable
public struct Arguments {
public let name: String
public init(name: String) { self.name = name }
}
public func getMessages(arguments: Arguments) async throws -> Messages {
[
.user("You are a friendly assistant helping \(arguments.name)."),
.assistant("Hey \(arguments.name)! What can I help you with?"),
]
}
}
For detailed patterns and API reference, load files from the reference/ directory:
{
"mcpServers": {
"$ARGUMENTS[0]": {
"command": "/path/to/$ARGUMENTS[0]"
}
}
}
swift build
swift run $ARGUMENTS[0]
swift test
swift build -c release
tools
Generate a complete MCP server project in Swift using the FastMCP library. Use when asked to create a Swift MCP server, build an MCP tool server, or scaffold a Model Context Protocol project in Swift.
tools
Use when work should span one or more detached tasks but still behave like one job with a single owner context. TaskFlow is the durable flow substrate under authoring layers like Lobster, ACPX, plugins, or plain code. Keep conditional logic in the caller; use TaskFlow for flow identity, child-task linkage, waiting state, revision-checked mutations, and user-facing emergence.
tools
# Lobster Lobster executes multi-step workflows with approval checkpoints. Use it when: - User wants a repeatable automation (triage, monitor, sync) - Actions need human approval before executing (send, post, delete) - Multiple tool calls should run as one deterministic operation ## When to use Lobster | User intent | Use Lobster? | | ------------------------------------------------------ | --------------------------
tools
# Lobster Lobster executes multi-step workflows with approval checkpoints. Use it when: - User wants a repeatable automation (triage, monitor, sync) - Actions need human approval before executing (send, post, delete) - Multiple tool calls should run as one deterministic operation ## When to use Lobster | User intent | Use Lobster? | | ------------------------------------------------------ | --------------------------