{% extends "admin/_layout.html" %}
{% from "_macros.html" import icon %}
{% set section = "mcp" %}

{% block title %}MCP servers - {{ brand.name }}{% endblock %}
{% block heading %}MCP servers{% endblock %}

{% block admin_content %}
<p class="admin-lede">
  Remote servers speaking the Model Context Protocol over HTTP. Their tools are
  offered beside the built-in ones to models marked <strong>MCP servers</strong>.
  The list of tools is discovered and cached — press <strong>Test &amp;
  refresh</strong> after adding one, and again whenever the server changes.
</p>

<div class="alert">
  {{ icon("shield", "icon--sm") }}
  <span>
    A server's tool names and descriptions are sent to the model as
    instructions, and what it returns is read back as fact. Add servers you
    trust, the way you would a dependency.
  </span>
</div>

{% if saved %}
<div class="alert alert--success">{{ icon("check", "icon--sm") }} <span>{{ saved }}</span></div>
{% endif %}

<div class="btn-row">
  <a class="btn btn--primary" href="/admin/mcp/new">
    {{ icon("plus", "icon--sm") }} Add a server
  </a>
</div>

{% if not servers %}
<div class="empty" style="padding: var(--sp-10) 0">
  {{ icon("server", "empty__mark") }}
  <p class="empty__text">
    No servers yet. You will need the URL of an MCP endpoint that speaks
    streamable HTTP — local ones launched as a subprocess are not supported.
  </p>
</div>
{% else %}

<div class="model-rows">
  {% for server in servers %}
  {% with tool_count = counts[server.id] %}
  {% include "admin/_mcp_row.html" %}
  {% endwith %}
  {% endfor %}
</div>
{% endif %}
{% endblock %}
