home / mcp / mcp template mcp server
A minimal MCP server template using the MCP Swift SDK with a sample CLI tool for basic interaction.
Configuration
View docs{
"mcpServers": {
"adamwulf-mcp-template": {
"command": "mcpexample",
"args": [
"run"
]
}
}
}You can run and test a lightweight MCP server designed for macOS applications and command line tools. This server provides a minimal integration example using the MCP protocol, along with a simple command line tool to illustrate how MCP interactions are handled end to end. It’s ideal when you want a quick, runnable starting point to explore MCP concepts and build your own server on top of a small, clean foundation.
Use the included command line tool to interact with the MCP server through standard input/output, or run the server to handle full MCP protocol communications. You can register a sample tool that greets a user, start the MCP server, and then connect to it with an MCP client or inspector. The sequence below shows a practical pattern you can follow to verify basic MCP functionality and observe how tools are invoked and results returned.
# Prerequisites
- macOS development environment
- Swift toolchain installed
# 1) Clone or fork the project (if starting from a template you already have the code locally)
# (Replace with your actual repository path if you are cloning)
# git clone https://github.com/your-username/mcp-template.git
# cd mcp-template
# 2) Build the package
swift build
# 3) Run tests (optional but recommended during development)
swift test
# 4) Run the example command line tool to verify MCP behavior
# This starts with a simple "hello" command and then a full MCP server run
./mcpexample runIf you want to exercise just the minimal CLI interaction, you can run the hello command first to see the tool registration in action, then start the run command to engage the MCP server in stdio transport mode.
Configuration focuses on a small, self-contained setup for demonstration. The template demonstrates how to wire an MCP library into a Swift project and how to expose a minimal tool that responds with a greeting. You can extend the provided tool to perform asynchronous work, call other services, or integrate with your app’s data sources.
Security considerations: keep the CLI and server usage within trusted environments during development. For production deployments, add appropriate authentication and access controls if you expose MCP endpoints over the network. Review your app’s security model to ensure only authorized clients can invoke tools and access results.
Troubleshooting tips: if the server does not start as expected, verify build success, confirm the runtime command is available on your PATH, and check any logs produced by the tool or server. Use a local inspector tool to observe MCP interactions and verify that the hello tool returns the expected greeting.
Registers a tool that returns a friendly greeting message and demonstrates how input is received and processed within an MCP tool.