AI Agent with MCP

by moises-paschoalick

2 stars
172 downloads
Not rated
GitHub

About

Este projeto é um playground para criar o primeiro servidor MCP (Model Context Protocol), um protocolo que permite integrar LLMs a recursos externos de forma padronizada.

Details

Author
moises-paschoalick
GitHub stars
2
Downloads
172
Categories
Developer Tools, AI, API

- Provides api://users resource listing all registered users.
- Provides hello://world resource returning a simple greeting.
- Includes a functional MCP client built with the official SDK.
- Supports installation via Smithery CLI or manual Cursor config.
- Allows direct REST API access to resources.

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name AI Agent with MCP
    Command (node, npx, python, etc.)

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository

Install the server via npx -y @smithery/cli@latest install @wonderwhy-er/desktop-commander --client cursor --key <your-key>, or manually add it to your mcp.json file (Mac/Linux or Windows). You can also clone the repository and run npm run setup. After installation, use the provided TypeScript client code to connect and list resources, or access resources directly via REST (e.g., curl http://3.238.149.189:8080/users).

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

{
    "mcpServers": {
        "ai agent with mcp": {
            "ai-agent-with-mcp": {
                "command": "npx",
                "args": [
                    "-y",
                    "@smithery/cli@latest",
                    "install",
                    "@wonderwhy-er/desktop-commander",
                    "--client",
                    "cursor",
                    "--key",
                    "dda23bec-caa6-4487-a1e9-eb74e22e33eb"
                ]
            }
        }
    }
}

McpServers

{
    "ai-agent-with-mcp": {
        "command": "npx",
        "args": [
            "-y",
            "@smithery/cli@latest",
            "install",
            "@wonderwhy-er/desktop-commander",
            "--client",
            "cursor",
            "--key",
            "dda23bec-caa6-4487-a1e9-eb74e22e33eb"
        ]
    }
}

Criando um MCP server com NodeJS (ai-agent-with-mcp)

Este projeto implementa um agente de IA que utiliza o Model Context Protocol (MCP) para interagir com recursos externos.

O repositório inclui:

Um servidor MCP funcional, com recursos REST para usuários e mensagens.

Um cliente MCP para consumir esses recursos via protocolo.

Exemplos práticos de como acessar os recursos por terminal, via API REST ou diretamente no Cursor.

Recursos Disponíveis

O servidor MCP fornece os seguintes recursos:

Recursos de Usuários

- api://users: Lista todos os usuários cadastrados no sistema - Retorna informações como ID, nome, número de telefone e thread ID - Formato: JSON - Exemplo de resposta:
    {
      "content": [
        {
          "id": 1,
          "phoneNumber": "553496341404",
          "name": "Moisés Paschoalick",
          "threadId": "thread_bZEPVYVBvHxY9Ok6WqR63M2D"
        },
        {
          "id": 2,
          "phoneNumber": "553496338888",
          "name": "José Silva",
          "threadId": "1thread_t8SFjKio6yN9pppqypilwGoR__"
        },
        {
          "id": 3,
          "phoneNumber": "553496338889",
          "name": "Maria Antonia",
          "threadId": "1thread_t8SFjKio6yN9pppqypilwGoR__"
        }
      ],
      "pageable": {
        "pageNumber": 0,
        "pageSize": 12,
        "sort": {
          "empty": false,
          "sorted": true,
          "unsorted": false
        },
        "offset": 0,
        "paged": true,
        "unpaged": false
      },
      "last": true,
      "totalPages": 1,
      "totalElements": 3,
      "first": true,
      "size": 12,
      "number": 0,
      "sort": {
        "empty": false,
        "sorted": true,
        "unsorted": false
      },
      "numberOfElements": 3,
      "empty": false
    }
    

Recursos de Mensagens

- hello://world: Retorna uma mensagem de saudação simples - Formato: texto plano (text/plain) - Exemplo de resposta: "Hello, World! This is my first MCP resource."

Instalação para Cursor

Primeiro, certifique-se de que você tem o Cursor instalado e o npm configurado em seu sistema.

Opção 1: Instalação via Terminal

Execute o seguinte comando no terminal:
npx -y @smithery/cli@latest install @wonderwhy-er/desktop-commander --client cursor --key dda23bec-caa6-4487-a1e9-eb74e22e33eb

Obs: a key mencionada é somente para exemplo, você precisa adicionar a sua.

Reinicie o Cursor se estiver em execução.

Opção 2: Instalação Manual

Adicione a entrada apropriada ao seu arquivo mcp.json:

Para Mac/Linux:

No Linux: ~/.config/cursor.json
{
  "mcpServers": {
    "desktop-commander": {
      "command": "npx",
      "args": [
        "-y",
        "@smithery/cli@latest",
        "run",
        "@wonderwhy-er/desktop-commander",
        "--key",
        "dda23bec-caa6-4487-a1e9-eb74e22e33eb"
      ]
    }
  }
}

Para Windows:

{
  "mcpServers": {
    "desktop-commander": {
      "command": "cmd",
      "args": [
        "/c",
        "npx",
        "-y",
        "@smithery/cli@latest",
        "run",
        "@wonderwhy-er/desktop-commander",
        "--key",
        "dda23bec-caa6-4487-a1e9-eb74e22e33eb"
      ]
    }
  }
}

Reinicie o Cursor se estiver em execução.

Opção 3: Clonar localmente

Clone e construa:
git clone https://github.com/moises-paschoalick/ai-agent-with-mcp.git
cd ai-agent-with-mcp
npm run setup

Reinicie o Cursor se estiver em execução.

O comando de configuração irá:
- Instalar dependências
- Construir o servidor
- Configurar o Cursor
- Adicionar servidores MCP à configuração do Cursor, se necessário

Como Usar

Cliente MCP

O projeto inclui um cliente MCP que pode ser usado para acessar os recursos disponíveis:

import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";

async function main() {
const client = new Client({
name: "hello-mcp-client",
version: "1.0.0"
});
const transport = new StdioClientTransport({
command: "node",
args: ["build/index.js"]
});

try {
await client.connect(transport);

// Listar recursos disponíveis
const resources = await client.listResources();
console.log("Recursos disponíveis:", resources);

// Ler o recurso de usuários
const content = await client.readResource({ uri: "api://users" });
console.log("\nLista de Usuários:", content);
} catch (error) {
console.error("Erro ao executar o cliente:", error);
}
}

main().catch(console.error);

API REST Direta

Você também pode acessar os recursos diretamente via API REST:

```bash

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.