A Swift library that turns any ArgumentParser CLI into an MCP server, letting AI agents call your commands as tools.
{
"mcpServers": {
"swift-argument-parser-mcp": {
"command": "<see-readme>",
"args": []
}
}
}No install config available. Check the server's README for setup instructions.
Are you the author?
Add this badge to your README to show your security score and help users find safe servers.
A Swift library that turns any ArgumentParser CLI into an MCP server, letting AI agents call your commands as tools.
Is it safe?
No package registry to scan.
No authentication — any process on your machine can connect.
Apache-2.0. View license →
Is it maintained?
Last commit 1 days ago. 2 stars.
Will it work with my client?
Transport: stdio. Works with Claude Desktop, Cursor, Claude Code, and most MCP clients.
Turn any Swift CLI into an MCP server in minutes.
ArgumentParserMCP lets AI agents call your Swift Argument Parser commands as tools via the Model Context Protocol. Add one conformance, register your commands, and your CLI is ready for Claude, Cursor, and other MCP clients.
Start with a regular Argument Parser command and conform it to MCPCommand:
import ArgumentParser
import ArgumentParserMCP
struct RepeatPhrase: ParsableCommand, MCPCommand {
static let configuration = CommandConfiguration(
abstract: "Repeat a phrase multiple times."
)
@Flag(help: "Include a counter with each repetition.")
var includeCounter = false
@Option(name: .shortAndLong, help: "How many times to repeat 'phrase'.")
var count: Int? = nil
@Argument(help: "The phrase to repeat.")
var phrase: String
mutating func run() throws {
let repeatCount = count ?? 2
for i in 1...repeatCount {
if includeCounter {
print("\(i): \(phrase)")
} else {
print(phrase)
}
}
}
}
Then add a subcommand that starts the MCP server:
import ArgumentParser
import ArgumentParserMCP
struct MCP: AsyncParsableCommand {
static let configuration = CommandConfiguration(
abstract: "MCP Server for AI agents"
)
mutating func run() async throws {
let server = MCPServer(
name: "my-cli",
version: "1.0.0",
commands: [RepeatPhrase.self]
)
try await server.start()
}
}
Register both subcommands in your root command:
@main
struct MyCLI: AsyncParsableCommand {
static let configuration = CommandConfiguration(
subcommands: [
RepeatPhrase.self,
MCP.self,
]
)
}
That's it. Your CLI now speaks MCP over stdio when invoked with the mcp subcommand:
$ my-cli mcp
The library automatically introspects your CLI via --experimental-dump-help,
generates JSON Schema for every registered command,
and dispatches tool calls back to the same binary as subprocesses.
AI Agent ──stdio──> my-cli mcp (MCPServer)
|
|── tools/list -> tool definitions from --experimental-dump-help
|
└── tools/call -> my-cli repeat-phrase --count 3 "hello"
captures stdout, returns as text
MCPServer runs the current executable with --experimental-dump-help
to discover the full command tree and argument metadata.MCPCommand, it builds an MCP tool with a JSON Schema inputSchema
derived from the command's arguments, options, and flags.By default, the MCP tool description is built from CommandConfiguration.abstract and .discussion.
Override mcpDescription for a custom one:
extension RepeatPhrase: MCPCommand {
static var mcpDescription: String {
"Repeats a given phrase N times. Useful for testing and demonstrations."
}
}
Use transformArguments to add, remove, or modify CLI arguments before execution on a per-command basis:
extension Deploy: MCPCommand {
static func transformArguments(_ arguments: [String]) -> [String] {
arguments + ["--non-interactive"]
}
}
Pass arguments that should be appended to every command invocation:
let server = MCPServer(
name: "my-cli",
version: "1.0.0",
commands: [Deploy.self, Status.self],
g
... [View full README on GitHub](https://github.com/ilia3546/swift-argument-parser-mcp#readme)
No automated test available for this server. Check the GitHub README for setup instructions.
This server is missing a description. Tools and install config are also missing.If you've used it, help the community.
Add informationNo known vulnerabilities.
Have you used this server?
Share your experience — it helps other developers decide.
Sign in to write a review.
Dynamic problem-solving through sequential thought chains
A Model Context Protocol (MCP) server and CLI that provides tools for agent use when working on iOS and macOS projects.
The official Python SDK for Model Context Protocol servers and clients
An open-source AI agent that brings the power of Gemini directly into your terminal.
MCP Security Weekly
Get CVE alerts and security updates for Swift Argument Parser Mcp and similar servers.
Start a conversation
Ask a question, share a tip, or report an issue.
Sign in to join the discussion.