Cover image
Try Now
2025-04-14

Servidor MCP Usando .net

3 years

Works with Finder

1

Github Watches

0

Github Forks

1

Github Stars

Building Your First MCP Server with .NET: A Developer's Guide to Model Context Protocol

Este repositório contém instruções detalhadas para construir e integrar um servidor MCP usando .NET, com o objetivo de expandir as funcionalidades de Modelos de Linguagem de Grande Porte (LLMs) em aplicações modernas.

Sobre o MCP

O Model Context Protocol (MCP) é um padrão aberto que facilita a comunicação bidirecional segura entre modelos de IA, ferramentas e APIs externas, permitindo interações mais estruturadas e previsíveis.

Funcionalidades

  • Conexão de LLMs com ferramentas e fontes de dados externas.
  • Criação de um servidor MCP em .NET para fornecer dados especializados, como informações de horário.
  • Integração do servidor MCP com o Cursor IDE como cliente MCP.

Melhorias

  1. Adição de Logs:

    • Logs foram introduzidos em Program.cs para facilitar a depuração e monitorar o comportamento do servidor MCP.
  2. Validação de Entrada:

    • O método GetTimeInTimezone agora verifica se o parâmetro de fuso horário não está vazio ou nulo antes de processá-lo, evitando erros desnecessários.
  3. Mensagens de Erro Detalhadas:

    • Tratamento aprimorado de exceções em GetTimeInTimezone com mensagens específicas, como para fusos horários inválidos ou não encontrados.
  4. Formato Configurável de Hora:

    • Data e hora foram formatadas (dd/MM/yyyy HH:mm:ss) para maior legibilidade, com possibilidade de personalização.
  5. Estrutura com Namespaces:

    • Organizei as classes em namespaces (McpTimeServer e McpTimeServer.Tools) para melhor separação lógica e escalabilidade.
  6. Código mais robusto e organizado:

    • As alterações tornam o servidor MCP mais confiável, preparado para crescimentos futuros e com melhor clareza para equipes de desenvolvimento.

Passos para Configuração

Criação do Projeto

Crie um novo aplicativo de console:

dotnet new console -n McpTimeServer
cd McpTimeServer

Instalação de Dependências

Adicione os pacotes necessários:

dotnet add package ModelContextProtocol --prerelease
dotnet add package Microsoft.Extensions.Hosting

Implementação do Servidor

Configure o servidor MCP em Program.cs:

builder.Services
    .AddMcpServer()
    .WithStdioServerTransport()
    .WithToolsFromAssembly();

Implemente ferramentas como métodos para funcionalidades específicas:

public static string GetCurrentTime() { return DateTimeOffset.Now.ToString(); }

Integração com Cursor IDE

Adicione o servidor MCP ao arquivo de configuração mcp.json no Cursor IDE:

{
  "mcpServers": {
    "timeServer": {
      "command": "dotnet",
      "args": ["run", "--project", "path/to/your/McpTimeServer"]
    }
  }
}

Origem do Conteúdo

As instruções deste repositório são baseadas no artigo "Building Your First MCP Server with .NET: A Developer's Guide to Model Context Protocol", escrito por Engincan Veske. O conteúdo original pode ser encontrado neste link.


Contribuição

Sinta-se à vontade para abrir Issues ou enviar Pull Requests para melhorar este guia ou adicionar novas funcionalidades.


Links Úteis


相关推荐

  • av
  • Ejecute sin esfuerzo LLM Backends, API, frontends y servicios con un solo comando.

  • 1Panel-dev
  • 🔥 1Panel proporciona una interfaz web intuitiva y un servidor MCP para administrar sitios web, archivos, contenedores, bases de datos y LLM en un servidor de Linux.

  • rulego
  • ⛓️Rulego es un marco de motor de regla de orquestación de componentes de alta generación de alto rendimiento, de alto rendimiento y de alto rendimiento para GO.

  • WangRongsheng
  • 🧑‍🚀 全世界最好的 llM 资料总结(数据处理、模型训练、模型部署、 O1 模型、 MCP 、小语言模型、视觉语言模型) | Resumen de los mejores recursos del mundo.

  • Byaidu
  • Traducción de papel científico en PDF con formatos preservados - 基于 Ai 完整保留排版的 PDF 文档全文双语翻译 , 支持 支持 支持 支持 支持 支持 支持 支持 支持 支持 支持 支持 等服务 等服务 等服务 提供 提供 提供 提供 提供 提供 提供 提供 提供 提供 提供 提供 cli/mcp/docker/zotero

  • hkr04
  • SDK liviano C ++ MCP (Protocolo de contexto del modelo)

  • sigoden
  • Cree fácilmente herramientas y agentes de LLM utilizando funciones Plain Bash/JavaScript/Python.

  • RockChinQ
  • 😎简单易用、🧩丰富生态 - 大模型原生即时通信机器人平台 | 适配 Qq / 微信(企业微信、个人微信) / 飞书 / 钉钉 / Discord / Telegram / Slack 等平台 | 支持 Chatgpt 、 Deepseek 、 DiFy 、 Claude 、 Gemini 、 Xai 、 PPIO 、 Ollama 、 LM Studio 、阿里云百炼、火山方舟、 Siliconflow 、 Qwen 、 Moonshot 、 Chatglm 、 SillyTraven 、 MCP 等 LLM 的机器人 / Agente | Plataforma de bots de mensajería instantánea basada en LLM, admite Discord, Telegram, WeChat, Lark, Dingtalk, QQ, Slack

  • lasso-security
  • Una puerta de enlace basada en complementos que orquesta otros MCP y permite a los desarrolladores construir sobre agentes de grado empresarial de TI.

  • modelscope
  • Iniciar aplicaciones de múltiples agentes empoderadas con Building LLM de manera más fácil.

    Reviews

    2.8 (11)
    Avatar
    user_dMLHtph5
    2025-04-26

    As a devoted user of MCP applications, I am thoroughly impressed with ABM_08_McpTimeServer by AdelinoBard. This product is highly reliable and efficient, making time management seamless and hassle-free. It integrates smoothly with other systems, enhancing overall productivity. I highly recommend this for anyone in need of a robust time server solution.

    Avatar
    user_L67S02CM
    2025-04-26

    The ABM_08_McpTimeServer by AdelinoBard is an exceptional tool for time synchronization within MCP applications. Its seamless integration and user-friendly interface make it a must-have for anyone looking to ensure precise timekeeping across their systems. Highly recommend for its reliability and efficiency!

    Avatar
    user_ZbDH7RNs
    2025-04-26

    As a dedicated user of the ABM_08_McpTimeServer by AdelinoBard, I cannot recommend this product enough. Its seamless integration and robust performance ensure accurate time synchronization across all connected devices. The user-friendly interface and comprehensive documentation make it an essential tool for anyone needing reliable time management solutions. The welcoming initial setup experience is also a great touch, highlighting the developer's focus on user experience.

    Avatar
    user_OxCmdIsn
    2025-04-26

    As a dedicated user of the ABM_08_McpTimeServer by AdelinoBard, I am thoroughly impressed with its performance and reliability. This time server has significantly improved my workflow with its precise time synchronization capabilities. The user interface is intuitive, and the setup was seamless. Highly recommended for anyone looking for a robust time server solution!

    Avatar
    user_YMWDQLbC
    2025-04-26

    I have been using the ABM_08_McpTimeServer for a while now, and I must say, it's an impressive tool. AdelinoBard did an excellent job with this application. It’s efficient, user-friendly, and integrates seamlessly with my existing setup. Highly recommend for anyone needing a reliable time server solution.

    Avatar
    user_NJAkTIjI
    2025-04-26

    As a dedicated user of the ABM_08_McpTimeServer developed by AdelinoBard, I am thoroughly impressed with its performance. This time server is incredibly reliable and efficient, making it an essential tool for keeping my systems synchronized. The seamless integration and user-friendly interface have significantly improved my workflow. Highly recommended to anyone in need of a trustworthy time server solution!

    Avatar
    user_mD9SjAWV
    2025-04-26

    As a dedicated user of ABM_08_McpTimeServer by AdelinoBard, I can confidently say this tool has significantly streamlined our time synchronization processes. Its robust and reliable performance ensures our systems remain accurately aligned. Highly recommended for anyone needing precise time management solutions!

    Avatar
    user_ItZdHijt
    2025-04-26

    ABM_08_McpTimeServer by AdelinoBard is an incredibly reliable and efficient time management tool. As a dedicated McP application user, I found this product to be a game-changer in maintaining synchronized and precise time across various systems. The seamless integration and user-friendly interface have significantly improved our operational efficiency. Highly recommend it!

    Avatar
    user_zupQOww9
    2025-04-26

    ABM_08_McpTimeServer by AdelinoBard is an exceptional time server application. Reliable and efficient, it has vastly improved our workflow. The user interface is intuitive and easy to set up, making it accessible for both beginners and professionals. Highly recommend it for anyone in need of a robust time server solution.

    Avatar
    user_iak8BK4J
    2025-04-26

    ABM_08_McpTimeServer by AdelinoBard is an exceptional time server tool. Its user-friendly interface and seamless integration make it a must-have for time management. I've been using it consistently and it never disappoints. Highly recommend this product!

    Avatar
    user_KAs5IXw2
    2025-04-26

    As a dedicated user of the ABM_08_McpTimeServer created by AdelinoBard, I am thoroughly impressed with its seamless time management capabilities. The product is intuitive and reliable, ensuring my tasks are always synchronized accurately. It has vastly improved my productivity and coordination across projects. Highly recommend it to anyone needing a robust time server solution.