{% extends "dashboard/base.html" %} {% block title %}{% if lang == 'fa' %}کلیدهای API{% else %}API Keys{% endif %} - MCP Hub{% endblock %} {% block page_title %}{% if lang == 'fa' %}کلیدهای API{% else %}API Keys{% endif %}{% endblock %} {% block content %}
{% if is_admin %} {# ── Admin view: full filters, all project keys ── #}

{% if lang == 'fa' %}مدیریت کلیدهای API (Admin){% else %}Manage project API keys (admin){% endif %}

{% if lang and lang != 'en' %}{% endif %}
{% if search_query or selected_project or selected_status != 'active' %} {{ t['clear'] }} {% endif %}
{% if api_keys %} {% for key in api_keys %} {% endfor %} {% else %} {% endif %}
{% if lang == 'fa' %}شناسه{% else %}Key ID{% endif %} {% if lang == 'fa' %}پروژه{% else %}Project{% endif %} {% if lang == 'fa' %}دسترسی{% else %}Scope{% endif %} {% if lang == 'fa' %}توضیحات{% else %}Description{% endif %} {% if lang == 'fa' %}وضعیت{% else %}Status{% endif %} {% if lang == 'fa' %}استفاده{% else %}Usage{% endif %} {% if lang == 'fa' %}عملیات{% else %}Actions{% endif %}
{{ key.key_id[:12] }}...
{% if key.project_id == '*' %} {% if lang == 'fa' %}همه پروژه‌ها{% else %}All Projects{% endif %} {% else %}{{ key.project_id }}{% endif %}
{% for scope in key.scope.split() %} {{ scope }} {% endfor %}
{{ key.description or '-' }} {% if key.revoked %}
{% if lang == 'fa' %}لغو شده{% else %}Revoked{% endif %}
{% else %}
{% if lang == 'fa' %}فعال{% else %}Active{% endif %}
{% endif %}
{{ key.usage_count }}
{% if not key.revoked %} {% endif %}

{% if lang == 'fa' %}کلید API یافت نشد{% else %}No API keys found{% endif %}

{% if total_pages > 1 %}

{% if lang == 'fa' %}نمایش {{ ((page_number-1)*per_page)+1 }} تا {{ [page_number*per_page, total_count]|min }} از {{ total_count }}{% else %}Showing {{ ((page_number-1)*per_page)+1 }}–{{ [page_number*per_page, total_count]|min }} of {{ total_count }}{% endif %}

{% if page_number > 1 %}{% if lang == 'fa' %}قبلی{% else %}Previous{% endif %}{% endif %} {% for p in range(1, total_pages+1) %}{% if p == page_number %}{{ p }}{% elif p == 1 or p == total_pages or (p >= page_number-2 and p <= page_number+2) %}{{ p }}{% endif %}{% endfor %} {% if page_number < total_pages %}{% if lang == 'fa' %}بعدی{% else %}Next{% endif %}{% endif %}
{% endif %}
{% else %} {# ── User view: personal keys with scope selector ── #}

{% if lang == 'fa' %}کلیدهای API شخصی برای دسترسی به MCP{% else %}Your personal API keys for MCP access{% endif %}

{% if lang == 'fa' %}فیلتر ابزارهای هر سایت در تنظیمات سایت انجام می‌شود.{% else %}Per-site tool filters are configured in Site Settings.{% endif %}

{% if user_keys %} {% for key in user_keys %} {% endfor %} {% else %} {% endif %}
{% if lang == 'fa' %}نام{% else %}Name{% endif %} Prefix {% if lang == 'fa' %}دسترسی{% else %}Scope{% endif %} Uses {{ t.actions }}
{{ key.name }} mhu_{{ key.key_prefix }}... {% if key.site_id %} {% for site in sites %}{% if site.id == key.site_id %}{{ site.alias }}{% endif %}{% endfor %} {% else %} {% if lang == 'fa' %}همه سرویس‌ها{% else %}All Services{% endif %} {% endif %} {{ key.use_count }}

{{ t.no_api_keys }}

{% if not is_admin %}

{% if lang == 'fa' %}نمونه کد پیکربندی{% else %}Configuration Snippet{% endif %}

{% if sites %}
{% if lang == 'fa' %}در حال بارگذاری...{% else %}Loading...{% endif %}

{% if lang == 'fa' %} نکته: تنظیمات بالا شامل نوع اتصال (streamableHttp برای Claude Desktop و http برای VS Code/Claude Code) می‌باشد. از sse استفاده نکنید — باعث خطای 400 Bad Request می‌شود. {% else %} Note: Config above includes the correct transport type (streamableHttp for Claude Desktop, http for VS Code/Claude Code). Do not use sse — it will cause 400 Bad Request errors. {% endif %}

{% if lang == 'fa' %} API Key: از بخش API Keys بالا بسازید و مقدار آن را در تنظیمات وارد کنید: {% else %} API Key: Create one above and use it in your config: {% endif %}

"Authorization": "Bearer mhu_YOUR_API_KEY_HERE"
{% else %}

{% if lang == 'fa' %}ابتدا یک سایت اضافه کنید.{% else %}Add a site first to see configuration snippets.{% endif %} {{ t.add_site }}

{% endif %}
{% endif %} {% endif %}
{# ── Modals ── #} {% if is_admin %} {% endif %} {% endblock %} {% block scripts %} {% endblock %}