mcp_server

mcp_server

0

This project is an implementation of the MCP Server for AI Agents. It supports easy integration with AI models and includes tools for weather forecasting and alerts. It is designed to work with GitHub Copilot amongst other platforms.

🤖 MCP Server

This repository contains the Model Context Protocol (MCP) Server used by AI Agents. It is built using the @modelcontextprotocol/sdk, which allows integration with various AI models. The project uses Node.js and TypeScript to provide a robust implementation of the MCP protocol.

The MCP (Model Context Protocol) is a protocol that enables standardized communication between applications and different AI models, making integration easier and more consistent.

🚀 Getting started

To start using the MCP Server, follow these steps:

Prerequisites

  • Node.js version 18 or higher
  • npm

Installation and build

Install dependencies and build the application:

npm install && npm run build

⚙️ MCP Server Configuration

To configure the MCP Server, you'll need to set up some environment variables. Use the .env.example file provided in the project as a reference. Copy it to a new .env file in the project root and adjust the settings as needed:

cp .env.example .env

Make sure to update the values in your .env file to match your specific environment and requirements.

🔌 Integrating with GitHub Copilot

Configuration in VS Code

The project already includes a pre-configured file for GitHub Copilot integration located in the .vscode/mcp.json folder. This is the recommended per-project configuration.

For external projects that want to use this MCP server, copy the following file to the .vscode folder of your project:

"mcp-server": {
  "type": "stdio",
  "command": "node",
  "args": ["${workspaceFolder}/build/index.js"],
  "envFile": "${workspaceFolder}/.env"
}

Alternatively, you can configure Copilot globally in VS Code settings:

  1. Open VS Code Settings (Ctrl+,)
  2. Search for "Copilot: Plugin"
  3. Click "Edit in settings.json"
  4. Add the following configuration:
"github.copilot.plugins": [
  {
    "name": "MCP",
    "command": "npm run start",
    "cwd": "/path/to/your/project/mcp"
  }
]

Replace /path/to/your/project/mcp with the absolute path to your MCP project.

Troubleshooting Common Issues

  • If Copilot does not recognize your plugin, try restarting VS Code.
  • Ensure the MCP SDK version is up to date.
  • Make sure the server is running before attempting to use the tools in Copilot.

🧰 Available Tools

This project comes with example tools:

  • get-alerts: Fetches weather alerts for a U.S. state.
  • get-forecast: Retrieves weather forecasts for specific coordinates.

📝 Testing with GitHub Copilot

After starting the server with npm run start and configuring VS Code, you can test your tools by asking Copilot to use them:

  • "Use the get-forecast tool to get the weather forecast for Detroit."
  • "Fetch weather alerts for California using the get-alerts tool."

🛠️ Creating New Tools

To create a new tool:

  1. Create a new file in the folder src/tools/[tool-name]/[tool-name].tool.ts
  2. Use the following structure as a template:
import { z } from "zod";
import server from "../../utils/server.config.js";

server.addTool(
  "tool-name",
  "Tool description",
  {
    parameter1: z.string().describe("Description of parameter 1"),
    parameter2: z.number().describe("Description of parameter 2"),
  },
  async ({ parameter1, parameter2 }) => {
    // Tool logic here

    return {
      content: [
        {
          type: "text",
          text: "Tool result",
        },
      ],
    };
  }
);
  1. Test the tool by calling it through the MCP Server API or using the provided tools.

📦 Creating New Resources

To create a new resource:

  1. Create a new file in the folder src/resources/[resource-name]/[resource-name].resource.ts
  2. Use the following structure as a template:
import { z } from "zod";
import server from "../../utils/server.config.js";

server.addResource(
  "resource-name",
  "Resource description",
  {
    parameter1: z.string().describe("Description of parameter 1"),
    parameter2: z.number().describe("Description of parameter 2"),
  },
  async ({ parameter1, parameter2 }) => {
    // Resource logic here

    return {
      data: {
        key: "value", // Replace with actual resource data
      },
    };
  }
);
  1. Test the resource by calling it through the MCP Server API or using the provided tools.

📓 Our conventions

Commit types / Branch prefixes

Here is the list of commit types and branch prefixes you can choose from :

Commit TypeTitleDescription
feat✨ FeaturesNew feature
fix🐛 Bug FixesBug fix
docs📚 DocumentationDocumentation only changes
style💎 StylesChanges that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
refactor📦 Code RefactoringA code change that neither fixes a bug nor adds a feature
perf🚀 Performance ImprovementsA code change that improves performance
test🚨 TestsAdding missing tests or correcting existing tests
build🛠 BuildsChanges that affect the build system or external dependencies (example scopes: next, webpack, pnpm)
ci⚙️ Continuous IntegrationsChanges to our CI configuration files and scripts
chore♻️ ChoresOther changes that don't modify src or test files
revert🗑 RevertsReverts a previous commit

Branch names

See the regex validating the branch naming .

Structure :

<type>/<short-description>

Examples :

feat/signup-page
ci/github-actions-setup
fix/calendar-input-focus-not-working

Commit messages

Structure :

<type>(optional scope): <description>

Examples :

ci(front): setup storybook tests
fix: send cors headers
feat(groups): add comment section