Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds MCP with Encore.ts example 💯 #219

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

leofmarciano
Copy link
Contributor

Weather MCP Demo Implementation

Overview

This PR introduces a fully functional Weather MCP (Model Context Protocol) demo built with Encore and TypeScript. The implementation showcases how to create an MCP server that provides weather information through a well-defined tool interface.

Features

  • MCP Server Implementation: Fully functional MCP server using the Model Context Protocol SDK
  • Weather Service: Provides current weather information for cities with proper error handling
  • Type Safety: Extensive use of TypeScript and Zod for schema validation
  • Testing: Comprehensive test suite using Vitest
  • Cursor Integration: Configuration for Cursor IDE to connect to the MCP server

Technical Details

Architecture

The project follows SOLID principles with a clear separation of concerns:

  • Controller Layer: WeatherController exposes the weather functionality as MCP tools
  • Service Layer: WeatherService contains business logic for fetching and formatting weather data
  • Repository Layer: WeatherRepository simulates data retrieval for weather information

Testing Strategy

The implementation follows Test-Driven Development (TDD) principles with:

  • Unit tests for the WeatherService
  • Integration tests for the MCP tool functionality
  • API tests for the Encore endpoints

MCP Tools

The demo implements the following MCP tools:

  • get-weather: Get the current weather for a specified city

How to Test

Running the Application

encore run

Running Tests

encore test

Testing MCP Functionality

./scripts/run-mcp-test.sh

Cursor Integration

The project includes configuration for Cursor IDE to connect to the MCP server. This allows Cursor to use the weather tool directly through the Model Context Protocol.

Future Improvements

  • Add more weather-related tools (forecast, historical data)
  • Implement a real weather API integration
  • Add more comprehensive error handling
  • Enhance documentation with JSDoc comments

Related Links

@encore-cla
Copy link

encore-cla bot commented Mar 18, 2025

All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant