Skip to main content
Glama
Dagudelot

MCP Server with OpenAI Integration

by Dagudelot

MCP Server with OpenAI Integration

Este proyecto demuestra cómo crear un servidor MCP (Model Context Protocol) personalizado con una herramienta de clima e integrarlo con OpenAI usando Cloudflare Tunnel.

🚀 Características

  • Servidor MCP personalizado con herramienta de clima

  • Integración automática con OpenAI usando tu propio código

  • Túnel de Cloudflare para exposición pública

  • TypeScript completamente tipado

  • Function calling automático sin intervención manual

Related MCP server: Python Weather MCP Server

📁 Estructura del Proyecto

mcp-server-openai-sdk/
├── src/
│   ├── index.ts              # Servidor MCP principal
│   ├── webhook-server.ts     # Servidor webhook para OpenAI
│   └── test-method2.ts       # Test de integración automática
├── package.json              # Dependencias y scripts
├── tsconfig.json            # Configuración TypeScript
├── .env                     # Variables de entorno (crear)
└── README.md                # Este archivo

🛠️ Instalación

  1. Instalar dependencias:

    npm install
  2. Configurar variables de entorno:

    # Crear archivo .env
    echo "OPENAI_API_KEY=tu-api-key-aqui" > .env
  3. Compilar el proyecto:

    npm run build

🚀 Uso

Paso 1: Iniciar el servidor webhook

npm run webhook

Paso 2: Crear túnel de Cloudflare

En otra terminal:

cloudflared tunnel --url http://localhost:3000

Paso 3: Actualizar la URL del túnel

Edita src/test-method2.ts y actualiza la URL:

const webhookUrl = "https://tu-nueva-url.trycloudflare.com/webhook/weather";

Paso 4: Probar la integración

npm run test

🎯 Cómo Funciona

Flujo Automático (Método 2)

  1. Usuario pregunta: "¿Cuál es el clima en Bogotá?"

  2. OpenAI detecta: Necesita información del clima

  3. Tu código llama automáticamente: Tu webhook de Cloudflare

  4. Tu MCP server responde: Con datos del clima

  5. Tu código envía: La respuesta de vuelta a OpenAI

  6. OpenAI presenta: La respuesta final naturalmente

Ejemplo de Salida

👤 Usuario: ¿Cuál es el clima en Bogotá?
🔧 Paso 1: OpenAI detecta que necesita información del clima
✅ OpenAI quiere llamar la función get_weather
🔄 Paso 2: Tu código llama automáticamente tu webhook
   📋 Argumentos: { "city": "Bogotá" }
✅ Paso 3: Tu MCP server responde: Weather in Bogotá: 15°C, cloudy
🔄 Paso 4: Tu código envía la respuesta de vuelta a OpenAI
🤖 Paso 5: OpenAI presenta la respuesta final:
   El clima en Bogotá es de 15°C, nublado.

🔧 Scripts Disponibles

  • npm run build - Compilar el proyecto

  • npm run webhook - Iniciar servidor webhook

  • npm run test - Probar integración automática

  • npm run dev - Modo desarrollo

🎯 Ventajas de esta Integración

Completamente automático - No necesitas intervención manual
Tu código controla todo - Manejas la comunicación
Escalable - Puedes agregar más herramientas fácilmente
Producción lista - Listo para usar en aplicaciones reales

🔍 Archivos Esenciales

  • src/index.ts - Servidor MCP con herramienta de clima

  • src/webhook-server.ts - Servidor webhook para OpenAI

  • src/test-method2.ts - Test de integración automática

📝 Notas

  • El servidor webhook debe estar corriendo en puerto 3000

  • El túnel de Cloudflare debe estar activo

  • La URL del túnel debe actualizarse en el script de test

  • Esta integración funciona completamente automática sin intervención manual

🎉 ¡Listo!

Tu servidor MCP personalizado está completamente integrado con OpenAI y funcionando automáticamente. Puedes hacer preguntas sobre el clima y obtener respuestas naturales sin intervención manual.

Available Tools

1 tool
get_weatherC

Get current weather information for a specific city

ParametersJSON Schema
NameRequiredDescriptionDefault
cityYesThe city to get weather information for
unitNoTemperature unitcelsius

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions 'Get current weather information,' which implies a read-only operation, but fails to describe error handling, rate limits, data sources, or response format. This leaves significant gaps in understanding the tool's behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core purpose without any wasted words. It is appropriately sized for a simple tool and earns its place by clearly stating the action and target.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the lack of annotations and output schema, the description is incomplete. It doesn't explain what weather information is returned (e.g., temperature, conditions), error scenarios, or any behavioral traits. For a tool with no structured support, this leaves the agent under-informed.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, clearly documenting both parameters. The description adds minimal value beyond the schema by implying the 'city' parameter is used for location, but it doesn't provide additional context like format examples or edge cases. Baseline 3 is appropriate given the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with a specific verb ('Get') and resource ('current weather information'), and specifies the target ('for a specific city'). It distinguishes what the tool does effectively, though there are no sibling tools to differentiate from, which prevents a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives, prerequisites, or exclusions. It simply states what the tool does without context for usage, leaving the agent with minimal direction.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 1 tool update
    • First observedget_weather

TDQS

B3/5.0

Scored across 1 tool

Disambiguation5/5

With only one tool, there is no possibility of confusion or overlap between tools, making disambiguation perfect.

Naming Consistency5/5

A single tool inherently has consistent naming, as there are no other tools to compare it against for patterns or deviations.

Tool Count2/5

One tool is too few for a server named 'MCP Server with OpenAI Integration', as this suggests a broader scope beyond just weather, making the count inappropriate for the apparent purpose.

Completeness1/5

The server's name implies OpenAI integration, but the only tool is for weather, leaving a severe gap in functionality for the stated domain, making it highly incomplete.

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    A server that integrates the MCP library with OpenAI's API, allowing users to interact with various tools, such as the weather tool, through natural language queries.
    MIT
  • A
    license
    B
    quality
    D
    maintenance
    Enables AI agents to fetch real-time weather data for any location using the OpenWeatherMap API. Demonstrates how to build a simple MCP server that exposes weather information as a tool for LLMs.
    1
    GPL 3.0