mcp_server
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:
- Open VS Code Settings (Ctrl+,)
- Search for "Copilot: Plugin"
- Click "Edit in settings.json"
- 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:
- Create a new file in the folder
src/tools/[tool-name]/[tool-name].tool.ts
- 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",
},
],
};
}
);
- Test the tool by calling it through the MCP Server API or using the provided tools.
📦 Creating New Resources
To create a new resource:
- Create a new file in the folder
src/resources/[resource-name]/[resource-name].resource.ts
- 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
},
};
}
);
- 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 Type | Title | Description |
---|---|---|
feat | ✨ Features | New feature |
fix | 🐛 Bug Fixes | Bug fix |
docs | 📚 Documentation | Documentation only changes |
style | 💎 Styles | Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc) |
refactor | 📦 Code Refactoring | A code change that neither fixes a bug nor adds a feature |
perf | 🚀 Performance Improvements | A code change that improves performance |
test | 🚨 Tests | Adding missing tests or correcting existing tests |
build | 🛠 Builds | Changes that affect the build system or external dependencies (example scopes: next, webpack, pnpm) |
ci | ⚙️ Continuous Integrations | Changes to our CI configuration files and scripts |
chore | ♻️ Chores | Other changes that don't modify src or test files |
revert | 🗑 Reverts | Reverts 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