{
  "info": {
    "name": "CCSM MCP | IA → MCP · cliente de IA",
    "_postman_id": "6e0bc01c-e079-485d-815e-04cb13162dd1",
    "description": "Esta colección representa las llamadas que ChatGPT u otro cliente de IA hace al MCP. La IA solicita la operación; el MCP crea una tarea asíncrona y devuelve task_id. La IA consulta get_bridge_task hasta su finalización, interpreta la salida y responde al usuario en su propia interfaz. La IA NO se comunica directamente con los equipos ni ejecuta shell. Usa user_token, nunca agent_token.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "item": [
    {
      "name": "IA solicita y consulta resultados en el MCP",
      "item": [
        {
          "name": "Inicializar protocolo MCP",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{user_token}}"
              },
              {
                "key": "Accept",
                "value": "application/json, text/event-stream"
              },
              {
                "key": "MCP-Protocol-Version",
                "value": "2025-11-25"
              }
            ],
            "url": {
              "raw": "{{base_url}}/mcp",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "mcp"
              ]
            },
            "body": {
              "mode": "raw",
              "raw": "{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"initialize\",\n  \"params\": {\n    \"protocolVersion\": \"2025-11-25\",\n    \"capabilities\": {},\n    \"clientInfo\": {\n      \"name\": \"Postman CCSM\",\n      \"version\": \"1.0\"\n    }\n  }\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "description": "Streamable HTTP puede devolver JSON o un evento SSE según el cliente. Usar token MCP individual, no el token del agente. El MCP puede requerir MCP-Session-Id para solicitudes siguientes; Postman no inicia ni interpreta una conversación ChatGPT."
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"MCP responde\",()=>pm.expect([200,202]).to.include(pm.response.code));",
                  "const s=pm.response.headers.get(\"Mcp-Session-Id\");if(s)pm.environment.set(\"mcp_session_id\",s);"
                ]
              }
            }
          ]
        },
        {
          "name": "Notificar sesión MCP inicializada (IA → MCP)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{user_token}}"
              },
              {
                "key": "Accept",
                "value": "application/json, text/event-stream"
              },
              {
                "key": "MCP-Protocol-Version",
                "value": "2025-11-25"
              }
            ],
            "url": {
              "raw": "{{base_url}}/mcp",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "mcp"
              ]
            },
            "body": {
              "mode": "raw",
              "raw": "{\n  \"jsonrpc\": \"2.0\",\n  \"method\": \"notifications/initialized\",\n  \"params\": {}\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "description": "ACTOR IA -> MCP. Tras initialize, el cliente confirma sesión inicializada (notificación JSON-RPC sin id). El servidor puede devolver 202 Accepted o 204 No Content. No es una llamada al agente Linux."
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Inicialización confirmada', () => pm.expect([200,202,204]).to.include(pm.response.code));"
                ]
              }
            }
          ]
        },
        {
          "name": "Listar herramientas MCP",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{user_token}}"
              },
              {
                "key": "Accept",
                "value": "application/json, text/event-stream"
              },
              {
                "key": "MCP-Protocol-Version",
                "value": "2025-11-25"
              }
            ],
            "url": {
              "raw": "{{base_url}}/mcp",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "mcp"
              ]
            },
            "body": {
              "mode": "raw",
              "raw": "{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 2,\n  \"method\": \"tools/list\",\n  \"params\": {}\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"HTTP 200\", function () { pm.response.to.have.status(200); });"
                ]
              }
            }
          ]
        },
        {
          "name": "Servidores asignados",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{user_token}}"
              },
              {
                "key": "Accept",
                "value": "application/json, text/event-stream"
              },
              {
                "key": "MCP-Protocol-Version",
                "value": "2025-11-25"
              }
            ],
            "url": {
              "raw": "{{base_url}}/mcp",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "mcp"
              ]
            },
            "body": {
              "mode": "raw",
              "raw": "{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 3,\n  \"method\": \"tools/call\",\n  \"params\": {\n    \"name\": \"list_my_linux_servers\",\n    \"arguments\": {}\n  }\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"HTTP 200\", function () { pm.response.to.have.status(200); });"
                ]
              }
            }
          ]
        },
        {
          "name": "Operaciones autorizadas del equipo",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{user_token}}"
              },
              {
                "key": "Accept",
                "value": "application/json, text/event-stream"
              },
              {
                "key": "MCP-Protocol-Version",
                "value": "2025-11-25"
              }
            ],
            "url": {
              "raw": "{{base_url}}/mcp",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "mcp"
              ]
            },
            "body": {
              "mode": "raw",
              "raw": "{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 4,\n  \"method\": \"tools/call\",\n  \"params\": {\n    \"name\": \"list_linux_commands\",\n    \"arguments\": {\n      \"agent_id\": \"{{agent_id}}\"\n    }\n  }\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"HTTP 200\", function () { pm.response.to.have.status(200); });"
                ]
              }
            }
          ]
        },
        {
          "name": "Solicitar operación read-only",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{user_token}}"
              },
              {
                "key": "Accept",
                "value": "application/json, text/event-stream"
              },
              {
                "key": "MCP-Protocol-Version",
                "value": "2025-11-25"
              }
            ],
            "url": {
              "raw": "{{base_url}}/mcp",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "mcp"
              ]
            },
            "body": {
              "mode": "raw",
              "raw": "{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 5,\n  \"method\": \"tools/call\",\n  \"params\": {\n    \"name\": \"run_linux_command\",\n    \"arguments\": {\n      \"agent_id\": \"{{agent_id}}\",\n      \"command\": \"system.uptime\"\n    }\n  }\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "description": "ACTOR IA -> MCP: solicitar operación autorizada. MCP encola y responde task_id, status queued. No se ejecuta durante esta solicitud. El agente toma la tarea mediante POST /api/v1/agent/pull. Luego IA consulta get_bridge_task."
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"HTTP 200\", function () { pm.response.to.have.status(200); });"
                ]
              }
            }
          ]
        },
        {
          "name": "Consultar resultado de la tarea",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{user_token}}"
              },
              {
                "key": "Accept",
                "value": "application/json, text/event-stream"
              },
              {
                "key": "MCP-Protocol-Version",
                "value": "2025-11-25"
              }
            ],
            "url": {
              "raw": "{{base_url}}/mcp",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "mcp"
              ]
            },
            "body": {
              "mode": "raw",
              "raw": "{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 6,\n  \"method\": \"tools/call\",\n  \"params\": {\n    \"name\": \"get_bridge_task\",\n    \"arguments\": {\n      \"task_id\": \"{{task_id}}\"\n    }\n  }\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "description": "ACTOR IA -> MCP: consultar tarea propia hasta completed/failed/expired. El MCP no publica automáticamente mensajes en ChatGPT. La IA interpreta el resultado y responde al usuario."
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"HTTP 200\", function () { pm.response.to.have.status(200); });"
                ]
              }
            }
          ]
        }
      ]
    }
  ],
  "variable": [
    {
      "key": "base_url",
      "value": "http://127.0.0.1:8011",
      "type": "string"
    },
    {
      "key": "user_token",
      "value": "",
      "type": "string"
    },
    {
      "key": "agent_id",
      "value": "",
      "type": "string"
    },
    {
      "key": "task_id",
      "value": "",
      "type": "string"
    },
    {
      "key": "mcp_session_id",
      "value": "",
      "type": "string"
    }
  ],
  "event": [
    {
      "listen": "prerequest",
      "script": {
        "type": "text/javascript",
        "exec": [
          "// Un cliente MCP puede recibir sesión desde initialize. Solo incluir header si existe.",
          "const session = pm.environment.get('mcp_session_id');",
          "if (session) { pm.request.headers.upsert({key:'Mcp-Session-Id',value:session}); }"
        ]
      }
    }
  ]
}
