Feedback

Chat Icon

Building with GitHub Copilot

From Autocomplete to Autonomous Agents

GitHub Copilot Agent Tools, Extensions, and MCPs
79%

Prototyping Your Own MCP Server

Each MCP server brings extra tools, APIs, and abilities to perform specialized tasks. Creating your own MCP server is not a wildly complex task. To get started, you can follow the MCP Server Guide, but the general steps can be summarized as follows:

  • Choose a programming language and framework (Python, Node.js, etc.).
  • Implement the MCP server interface (handle requests, responses).
  • Define the tools and functions your server will provide.
  • Test your server locally.
  • Deploy your server (locally, cloud, etc.).
  • Integrate with Copilot by adding it to your mcp.json or settings.json.

To better illustrate the process, let's create a simple server that provides system information about the host machine. The goal is not to create a production-ready server - this would require more work and it's out of the scope of this guide - but to show you how easy it is to create a simple MCP server.

Start by installing uv with the standalone installers or your package manager of choice.

This is the directory structure we will create:

MCPServers
├── mcp-sysinfo
│   ├── pyproject.toml
│   └── server.py

Create a new directory for your MCP server and navigate into it:

mkdir mcp-sysinfo && cd mcp-sysinfo

Create a lightweight pyproject so that uvx can resolve dependencies. Open pyproject.toml and add:

[project]
name = "mcp-sysinfo"
version = "0.0.1"
requires-python = ">=3.11"
dependencies = [
    "mcp[cli]",
    "typer>=0.16.1",
]

Let's write some code. Create a file named server.py and add:

# Import necessary modules for the MCP server
from dataclasses import asdict, dataclass  # asdict: convert dataclass to dict; dataclass: decorator for simple data classes
import os  # Provides functions for interacting with the operating system, like environment variables
import platform  # Module to access platform-specific information
import multiprocessing  # Module for multiprocessing, used here to get CPU count
from mcp.server.fastmcp import FastMCP  # Import FastMCP, the framework for building MCP servers

# Create an instance of FastMCP server named "SysInfo"
mcp = FastMCP("SysInfo")

# Define a data class to hold system information
@dataclass
class SysInfo:
    os: str  # Operating system name (e.g., 'Linux', 'Windows')
    version: str  # Operating system version
    arch: str  # Machine architecture (e.g., 'x86_64', 'arm64')
    cpu_count: int  # Number of CPU cores available
    home: str | None  # Path to the user's home directory, can be None if not set
    shell: str | None  # Default shell or command prompt, can be None

# Decorate the function to register it as an MCP tool
@mcp.tool()
def system_info() -> dict:
    """
    Return a minimal snapshot of the OS and simple configuration.
    """
    # Gather system information and create a SysInfo instance
    info = SysInfo(
        os=platform.system(),  # Get the operating system name
        version=platform.version(),  # Get the operating system version
        arch=platform.machine(),

Building with GitHub Copilot

From Autocomplete to Autonomous Agents

Enroll now to unlock all content and receive all future updates for free.