Skip to content

Conversation

@alakkaya
Copy link
Owner

📋 PR Description

Integrates MCP (Model Context Protocol) for Claude Desktop integration with NestJS Todo application.

✨ Changes

  • New: MCP server with JSON-RPC protocol communication
  • Auth Tools: User registration and login via Claude Desktop
  • Docker Ready: Separate MCP server container for isolation

🏗️ Architecture

MCP Server handles JSON-RPC requests → Auth Tools process commands →
NestJS services execute business logic → Structured responses to Claude Desktop

🧪 Available Tools

  • auth_register - Register new user with fullname, nickname, password
  • auth_login - Authenticate user and return JWT access token

Claude Desktop Setup Instructions

Prerequisites

  1. Docker Setup: Make sure your NestJS application is running in Docker
  2. Claude Desktop: Install Claude Desktop application
  3. Project Running: Ensure docker compose up is working

Step 1: Verify MCP Server is Running

# Start all containers including MCP server
cd docker && docker compose up

# Verify MCP server container is running
docker ps | grep mcp-server
# Should show: docker-mcp-server-1

Step 2: Configure Claude Desktop

  1. Find Claude Desktop Config File:

    • macOS: ~/.config/claude-desktop/claude_desktop_config.json
    • Windows: %APPDATA%\Claude\claude_desktop_config.json
    • Linux: ~/.config/claude-desktop/claude_desktop_config.json
  2. Create/Edit Config File:

{
  "mcpServers": {
    "nestjs-todo": {
      "command": "docker",
      "args": [
        "exec",
        "-i",
        "docker-mcp-server-1",
        "node",
        "dist/mcp-server.js"
      ]
    }
  }
}

Step 3: Restart Claude Desktop

  1. Quit Claude Desktop completely
  2. Restart Claude Desktop
  3. Verify Connection: You should see MCP server connected in Claude Desktop status

Step 4: Test MCP Integration

Try these example prompts in Claude Desktop:

Register a New User

Can you register a new user with:
- Full name: "John Doe"
- Nickname: "johndoe"
- Password: "secure123"

Login User

Can you login the user "johndoe" with password "secure123"?

Check Available Tools

What MCP tools are available in this application?

Expected Claude Response

Claude should be able to:

  • ✅ List available MCP tools (auth_register, auth_login)
  • ✅ Register new users via MCP
  • ✅ Login users and receive access tokens
  • ✅ Handle errors gracefully with custom exception messages

@alakkaya alakkaya self-assigned this Sep 19, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Integrates MCP (Model Context Protocol) support for Claude Desktop integration, enabling external tools to interact with the NestJS Todo application through JSON-RPC communication.

  • MCP server implementation with JSON-RPC protocol for Claude Desktop integration
  • Authentication tools for user registration and login via MCP interface
  • Docker containerization setup for isolated MCP server deployment

Reviewed Changes

Copilot reviewed 14 out of 15 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/modules/mcp/tools/auth.tools.ts Implements authentication tools for MCP with register and login functionality
src/modules/mcp/server/mcp.server.ts Core MCP server with JSON-RPC handlers and tool routing
src/modules/mcp/mcp.module.ts NestJS module configuration for MCP integration
src/mcp-server.ts Bootstrap entry point for standalone MCP server
src/core/interface/mcp/mcp-tool.const.ts Tool definitions and type utilities for MCP tools
src/core/interface/mcp/index.ts Export barrel for MCP interfaces
src/core/interface/index.ts Adds MCP interface exports
src/core/error/exception/mcp-tool-not-found.exception.ts Custom exception for missing MCP tools
src/core/error/exception/mcp-category-not-supported.exception.ts Custom exception for unsupported tool categories
src/core/error/exception/index.ts Exports new MCP exception classes
src/core/error/error-code.ts Error codes for MCP-related exceptions
src/app.module.ts Registers MCP module in main application
package.json Adds MCP SDK dependency and development script
docker/docker-compose.yml Configures separate MCP server container

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +59 to +64
async handleToolCall(toolName: string, args: any) {
switch (toolName) {
case McpTool.AUTH_REGISTER.name:
return await this.register(args);
case McpTool.AUTH_LOGIN.name:
return await this.login(args);
Copy link

Copilot AI Sep 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 'args' parameter should be properly typed instead of using 'any'. Consider creating a union type of the expected argument types (CreateUserDto | SignInDto) or using a generic parameter.

Suggested change
async handleToolCall(toolName: string, args: any) {
switch (toolName) {
case McpTool.AUTH_REGISTER.name:
return await this.register(args);
case McpTool.AUTH_LOGIN.name:
return await this.login(args);
async handleToolCall(toolName: string, args: CreateUserDto | SignInDto) {
switch (toolName) {
case McpTool.AUTH_REGISTER.name:
return await this.register(args as CreateUserDto);
case McpTool.AUTH_LOGIN.name:
return await this.login(args as SignInDto);

Copilot uses AI. Check for mistakes.
Comment on lines +68 to +78
} catch (error) {
return {
content: [
{
type: 'text',
text: `Error: ${error.message}`,
},
],
isError: true,
};
}
Copy link

Copilot AI Sep 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error handling assumes 'error.message' exists, but 'error' could be any type. Add proper type checking or cast error to Error type to ensure safe property access.

Copilot uses AI. Check for mistakes.
@Halil-Kaya
Copy link
Collaborator

bunun testi yazılabiliyor mu acaba? bunu bi araştırabilir misin

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.

3 participants