{"id":25438042,"url":"https://github.com/loopwork-ai/mcp-swift-sdk","last_synced_at":"2025-11-01T07:30:31.422Z","repository":{"id":277066753,"uuid":"927967893","full_name":"loopwork-ai/mcp-swift-sdk","owner":"loopwork-ai","description":"Swift SDK for Model Context Protocol servers and clients","archived":false,"fork":false,"pushed_at":"2025-02-11T23:27:41.000Z","size":39,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-02-12T00:25:33.472Z","etag":null,"topics":["mcp","swift"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/loopwork-ai.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-05T20:50:16.000Z","updated_at":"2025-02-11T23:26:46.000Z","dependencies_parsed_at":"2025-02-12T00:35:53.350Z","dependency_job_id":null,"html_url":"https://github.com/loopwork-ai/mcp-swift-sdk","commit_stats":null,"previous_names":["loopwork-ai/mcp-swift-sdk"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loopwork-ai%2Fmcp-swift-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loopwork-ai%2Fmcp-swift-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loopwork-ai%2Fmcp-swift-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loopwork-ai%2Fmcp-swift-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/loopwork-ai","download_url":"https://codeload.github.com/loopwork-ai/mcp-swift-sdk/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239264788,"owners_count":19610065,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["mcp","swift"],"created_at":"2025-02-17T09:28:35.114Z","updated_at":"2025-02-17T09:28:35.731Z","avatar_url":"https://github.com/loopwork-ai.png","language":"Swift","readme":"# MCP Swift SDK\n\nSwift implementation of the [Model Context Protocol][mcp] (MCP).\n\n## Requirements\n\n- Swift 6.0+ / Xcode 16+\n- macOS 14.0+ (Sonoma)\n- iOS 17.0+\n\n## Installation\n\n### Swift Package Manager\n\nAdd the following to your `Package.swift` file:\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/loopwork-ai/mcp-swift-sdk.git\", from: \"0.1.0\")\n]\n```\n\n## Usage\n\n### Basic Client Setup\n\n```swift\nimport MCP\n\n// Initialize the client\nlet client = Client(name: \"MyApp\", version: \"1.0.0\")\n\n// Create a transport and connect\nlet transport = StdioTransport()\ntry await client.connect(transport: transport)\n\n// Initialize the connection\nlet result = try await client.initialize()\n```\n\n### Basic Server Setup\n\n```swift\nimport MCP\n\n// Initialize the server with capabilities\nlet server = Server(\n    name: \"MyServer\", \n    version: \"1.0.0\",\n    capabilities: .init(\n        resources: .init(\n            list: true,\n            read: true,\n            subscribe: true\n        )\n    )\n)\n\n// Create transport and start server\nlet transport = StdioTransport()\ntry await server.start(transport: transport)\n\n// Register method handlers\nserver.withMethodHandler(ReadResource.self) { params in\n    // Handle resource read request\n    let uri = params.uri\n    let content = [Resource.Content.text(\"Example content\")]\n    return .init(contents: content)\n}\n\n// Register notification handlers\nserver.onNotification(ResourceUpdatedNotification.self) { message in\n    // Handle resource update notification\n}\n\n// Stop the server when done\nawait server.stop()\n```\n\n### Working with Tools\n\n```swift\n// List available tools\nlet tools = try await client.listTools()\n\n// Call a tool\nlet (content, isError) = try await client.callTool(\n    name: \"example-tool\", \n    arguments: [\"key\": \"value\"]\n)\n\n// Handle tool content\nfor item in content {\n    switch item {\n    case .text(let text):\n        print(text)\n    case .image(let data, let mimeType, let metadata):\n        // Handle image data\n    }\n}\n```\n\n### Working with Resources\n\n```swift\n// List available resources\nlet (resources, nextCursor) = try await client.listResources()\n\n// Read a resource\nlet contents = try await client.readResource(uri: \"resource://example\")\n\n// Subscribe to resource updates\ntry await client.subscribeToResource(uri: \"resource://example\")\n\n// Handle resource updates\nawait client.onNotification(ResourceUpdatedNotification.self) { message in\n    let uri = message.params.uri\n    let content = message.params.content\n    // Handle the update\n}\n```\n\n### Working with Prompts\n\n```swift\n// List available prompts\nlet (prompts, nextCursor) = try await client.listPrompts()\n\n// Get a prompt with arguments\nlet (description, messages) = try await client.getPrompt(\n    name: \"example-prompt\",\n    arguments: [\"key\": \"value\"]\n)\n```\n\n## License\n\nThis project is licensed under the Apache License, Version 2.0.\n\n[mcp]: https://modelcontextprotocol.io","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floopwork-ai%2Fmcp-swift-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Floopwork-ai%2Fmcp-swift-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floopwork-ai%2Fmcp-swift-sdk/lists"}