MCP Template

by adamwulf

17 stars
357 downloads
Not rated
GitHub Website

About

A barebones MCP server implementation in Swift using loopwork-ai's mcp-swift-sdk.

Details

Author
adamwulf
GitHub stars
17
Downloads
357
Categories
Developer Tools

- Basic Swift package structure for MCP server projects
- Command line "hello world" example tool
- Command line stdio transport for MCP interaction via run command
- Planned: App Store safe stdio and SSE server support
- Simple tool registration with async closures and error handling

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name MCP Template
    Command (node, npx, python, etc.)

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository

Add the package to your Package.swift dependencies, then import EasyMCP to register tools and start the server. The included command-line executable mcpexample offers a hello command for a basic demo and a run command to start a full MCP server with stdio transport. For debugging, use the MCP Inspector by running npx @modelcontextprotocol/inspector <path_to_executable> run.

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

{
    "mcpServers": {
        "mcp template": {
            "mcp-template": {
                "command": "npx",
                "args": [
                    "@modelcontextprotocol/inspector",
                    "<absolute_path_to_your_executable>",
                    "run"
                ]
            }
        }
    }
}

McpServers

{
    "mcp-template": {
        "command": "npx",
        "args": [
            "@modelcontextprotocol/inspector",
            "<absolute_path_to_your_executable>",
            "run"
        ]
    }
}

MCP Template

A template repository providing a barebones foundation for building Model Control Protocol (MCP) servers for macOS applications and command line tools.

Overview

MCP Template serves as a starting point for developers looking to implement MCP servers in their projects. This template demonstrates how to use the mcp-swift-sdk in a minimal way, making it easier to understand the basics of MCP integration. It includes both a library template for integration into other projects and a simple command-line example to illustrate basic usage.

Purpose

This repository is intended to be:
- A reference implementation showing how to use mcp-swift-sdk
- A template that can be forked or cloned as a foundation for your own MCP server implementations
- A barebones example that demonstrates core MCP concepts with minimal code

Features

Current and planned features include:

- [x] Basic Swift package structure
- [x] Command line "hello world" example tool
- [x] Command line stdio for direct MCP interaction via the run command
- [ ] App Store safe command line stdio → standalone Mac app communication
- [ ] SSE server in a Package → example command line app for SSE-based MCP

Installation

Swift Package Manager

Add the following to your Package.swift file:

dependencies: [
    .package(url: "https://github.com/your-username/mcp-template.git", branch: "main"),
]

Then add the dependency to your target:

.target(
    name: "YourTarget",
    dependencies: [
        .product(name: "EasyMCP", package: "mcp-template")
    ]
),

Usage

Basic Example

import EasyMCP

// Create an instance of EasyMCP
let mcp = EasyMCP()

// Register a tool
try await mcp.register(tool: Tool(
name: "helloPerson",
description: "Returns a friendly greeting message",
inputSchema: [
"type": "object",
"properties": [
"name": [
"type": "string",
"description": "Name of the person to say hello to",
]
],
"required": ["name"]
]
)) { input in
// It's an async closure, so you can await whatever you need to for long running tasks
await someOtherAsyncStuffIfYouWant()
// Return your result and flag if it is/not an error
return Result(content: [.text(hello(input["name"]?.stringValue ?? "world"))], isError: false)
}

// Start the MCP server for full MCP interaction
try await mcp.start()
try await mcp.waitUntilComplete()

Command Line Example

The package includes a command line executable called mcpexample that demonstrates basic usage:

```bash

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.