
cocoanetics/swiftmcp
Developer toolsこのページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。 原文を見る
cocoanetics/swiftMCPは、https://github.com/cocoanetics/swiftmcp.からインポートされたMCPサーバー候補です。
概要
cocoanetics/swiftMCPは、https://github.com/cocoanetics/swiftmcp.からインポートされたMCPサーバー候補です。
概要(AI 翻訳)
JSON-RPC向けのMCP(モデルコンテキストプロトコル)のSwift実装で、さまざまなトランスポートを経由します。
特徴
- 複数の輸送手段
- コマンドライン使用のための標準I/O(標準)
- HTTP+SSE(サーバー送信イベント) ウェブアプリケーション向け
- TCP+Bonjour:生のTCP上でローカルディスカバリーを行う
- OpenAPI生成に対応したJSON-RPC 2.0
- 組み込みの認可およびオプションのOAuth検証機能
- MCPおよびOpenAPI用の透過的なOAuthプロキシモード
- クロスプラットフォーム互換性
サーバー機能
- Tools –
@MCPToolで関数を公開します。 - リソース – [[T1]でデータを公開する
- Prompts –
@MCPPromptを使ったプロンプトの作成 - ユーティリティ
- 進行状況通知は
RequestContext.currentを経由しています。 - [[T4]を経由する構造化ログ
- パラメータの補完提案(
BoolおよびCaseIterableのデフォルト)
クライアント機能
- Roots – クライアントが発表する動的ファイルシステムの根
- サンプリング – クライアントファイルの小規模プレビューをリクエスト
設置
SwiftMCPをPackage.swiftに依存関係として追加してください:
パッケージ特性
このページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。
README
以下は原文 README の抜粋です。原文を見る。
SwiftMCP
A Swift implementation of the MCP (Model Context Protocol) for JSON-RPC over various transports.
Features
- Multiple transport options
- Standard I/O (stdio) for command-line usage
- HTTP+SSE (Server-Sent Events) for web applications
- TCP+Bonjour for local discovery over raw TCP
- JSON-RPC 2.0 compliant with OpenAPI generation
- Built-in authorization and optional OAuth validation
- Transparent OAuth proxy mode for MCP and OpenAPI
- Cross-platform compatibility
Server Features
- Tools – expose functions with
@MCPTool - Resources – publish data with
@MCPResource - Prompts – build prompts using
@MCPPrompt - Utilities
- Progress notifications via
RequestContext.current - Structured logging streamed through
Session.current - Completion suggestions for parameters (defaults for
BoolandCaseIterable)
- Progress notifications via
Client Features
- Roots – dynamic filesystem roots announced by the client
- Sampling – request small previews of client files
Installation
CI builds and tests with Swift 6.4 across macOS, iOS, Linux, Windows, and Android. Apple CI lanes use Xcode 27.1; Linux, Windows, and Android use Swift 6.4.2.
Add SwiftMCP as a dependency in your Package.swift:
dependencies: [
.package(url: "https://github.com/Cocoanetics/SwiftMCP.git", branch: "main")
]
Package traits
SwiftMCP exposes its optional feature areas as SwiftPM package traits, all enabled by default — existing consumers and a plain swift build are unaffected. The single import SwiftMCP module is unchanged.
| Trait | Enables | Extra dependencies |
|---|---|---|
Server |
HTTP/SSE + TCP server transports | swift-nio, swift-crypto, swift-certificates |
Client |
The MCP client (MCPServerProxy) |
— |
OpenAPI |
OpenAPI / AI-plugin manifest models and routes | — |
The tool/schema foundation — JSONValue, JSONSchema, MCPToolProviding, the @MCPTool / @MCPServer macros, errors — is always-on core and needs no trait.
Disabling Server drops swift-nio (and swift-crypto/swift-certificates) entirely, which makes the package build on Windows and gives client/tools-only consumers a lighter graph. A consumer that only talks to remote MCP servers selects just what it needs (your manifest must be swift-tools-version: 6.1 or newer to choose traits):
.package(
url: "https://github.com/Cocoanetics/SwiftMCP.git",
branch: "main",
traits: ["Client"] // tool/schema core + client, no swift-nio
)
AppIntents bridging (
@MCPAppIntentTool, AppShortcuts discovery) is not a trait: it is already gated by#if canImport(AppIntents), so it is automatically excluded on platforms without AppIntents (Linux, Windows, Android).
Usage
Command Line Demo
The included demo application shows how to use SwiftMCP with different transport options:
インストール
This server does not publish a one-line install command.
Open the repository installation guide MCP 初心者?mcpskill.org のガイドから始めましょう →