Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

fix(mcp): server-reported prompt descriptions and Skills-style paging (#3075)

rkrkrkkf05735ebb558
diff --git a/core/managed_skills.py b/core/managed_skills.py
index a278b90d5..c6e0a17db 100644
--- a/core/managed_skills.py
+++ b/core/managed_skills.py
@@ -11,7 +11,7 @@ import stat
import unicodedata
from dataclasses import dataclass, replace
from pathlib import Path
-from typing import Any, Sequence
+from typing import Any, Callable, Sequence, TypeVar
import yaml
@@ -37,6 +37,7 @@ SKILL_XDG_CONFIG_HOME_ENV = "AVIBE_SKILL_XDG_CONFIG_HOME"
CATALOG_PAGE_SIZE = 25
CATALOG_PAGE_MAX_BYTES = 16 * 1024
+T = TypeVar("T")
CATALOG_DESCRIPTION_MAX_CHARS = 1024
FRONTMATTER_MAX_BYTES = 64 * 1024
SKILL_BODY_MAX_BYTES = 256 * 1024
@@ -1008,44 +1009,39 @@ def resolve_skills(
return sorted(winners.values(), key=lambda skill: skill.name)
-def _catalog_pages(skills: Sequence[ManagedSkill]) -> list[list[ManagedSkill]]:
- pages: list[list[ManagedSkill]] = []
- current: list[ManagedSkill] = []
+def catalog_page_of(items: Sequence[T], row: Callable[[T], str], page: int) -> tuple[Sequence[T], int | None]:
+ """One prompt catalog page: at most ``CATALOG_PAGE_SIZE`` rows and ``CATALOG_PAGE_MAX_BYTES``, never empty."""
+
+ if isinstance(page, bool) or page < 1:
+ raise ValueError("page must be a positive integer")
+ pages: list[list[T]] = []
+ current: list[T] = []
current_bytes = 0
- for skill in sorted(
- skills,
- key=lambda item: (
- item.name.casefold(),
- item.name,
- item.description,
- str(item.directory),
- ),
- ):
- if skill.disable_model_invocation:
- continue
- row = f"- {skill.name}: {skill.description}"
- row_bytes = len(row.encode("utf-8")) + (1 if current else 0)
+ for item in items:
+ line = row(item)
+ row_bytes = len(line.encode("utf-8")) + (1 if current else 0)
if current and (len(current) >= CATALOG_PAGE_SIZE or current_bytes + row_bytes > CATALOG_PAGE_MAX_BYTES):
pages.append(current)
current = []
current_bytes = 0
- row_bytes = len(row.encode("utf-8"))
- current.append(skill)
+ row_bytes = len(line.encode("utf-8"))
+ current.append(item)
current_bytes += row_bytes
if current:
pages.append(current)
- return pages
-
-
-def catalog_page(skills: Sequence[ManagedSkill], page: int) -> tuple[Sequence[ManagedSkill], int | None]:
- if isinstance(page, bool) or page < 1:
- raise ValueError("page must be a positive integer")
- pages = _catalog_pages(skills)
if page > len(pages):
return (), None
return pages[page - 1], page + 1 if page < len(pages) else None
+def catalog_page(skills: Sequence[ManagedSkill], page: int) -> tuple[Sequence[ManagedSkill], int | None]:
+ listed = sorted(
+ (skill for skill in skills if not skill.disable_model_invocation),
+ key=lambda item: (item.name.casefold(), item.name, item.description, str(item.directory)),
+ )
+ return catalog_page_of(listed, lambda skill: f"- {skill.name}: {skill.description}", page)
+
+
def _skill_list_rows(entries: Sequence[ManagedSkill]) -> list[str]:
return [f"- {skill.name}: {skill.description}" for skill in entries]
diff --git a/core/mcp_hub/definition.py b/core/mcp_hub/definition.py
index 12488a364..8ee47c70d 100644
--- a/core/mcp_hub/definition.py
+++ b/core/mcp_hub/definition.py
@@ -21,7 +21,6 @@ HTTP = "streamable_http"
_STDIO_TYPES = {None, "stdio"}
_HTTP_TYPES = {"http", "streamable-http", "streamable_http"}
-_PROVIDER_FIELDS = {"type", "command", "args", "env", "cwd", "url", "headers", "enabled", "description"}
_PLACEHOLDER = re.compile(r"\$\{[^}]*\}")
_ENV_KEY = re.compile(r"^[A-Za-z_][A-Za-z0-9_]*$")
_HEADER_NAME = re.compile(r"^[!#$%&'*+.^_`|~0-9A-Za-z-]+$")
@@ -79,7 +78,7 @@ def _string_map(value: object, field: str, key_pattern: re.Pattern[str]) -> dict
def normalize_description(value: object) -> str:
- """One line, at most 160 characters; used for the prompt index and lists."""
+ """One line, at most 160 characters; the server-reported prompt description."""
if value is None:
return ""
@@ -88,7 +87,7 @@ def normalize_description(value: object) -> str:
return " ".join(value.split())[:DESCRIPTION_MAX]
-def definition_from_provider(name: str, server: object, *, description: object = None) -> dict[str, Any]:
+def definition_from_provider(name: str, server: object) -> dict[str, Any]:
"""Normalize one provider ``mcpServers`` entry into a persisted definition."""
validate_name(name)
@@ -107,12 +106,9 @@ def definition_from_provider(name: str, server: object, *, description: object =
has_url = "url" in server
if has_command and has_url:
raise _invalid("url", "Use either command (stdio) or url (Streamable HTTP), not both.")
- if description is None:
- description = server.get("description")
definition: dict[str, Any] = {
"schemaVersion": SCHEMA_VERSION,
"name": name,
- "description": normalize_description(description),
}
if has_url or kind in _HTTP_TYPES:
if kind not in _HTTP_TYPES | {None}:
@@ -221,7 +217,6 @@ def parse_add_argv(argv: list[str]) -> tuple[list[dict[str, Any]], bool]:
transport = "stdio"
env: dict[str, str] = {}
headers: dict[str, str] = {}
- description: Optional[str] = None
cwd: Optional[str] = None
replace = False
json_text: Optional[str] = None
@@ -261,8 +256,6 @@ def parse_add_argv(argv: list[str]) -> tuple[list[dict[str, Any]], bool]:
if not sep:
raise McpHubError("usage", f"--header expects 'Name: value', got {item!r}.", usage=True)
headers[key.strip()] = val.strip()
- elif option == "--description":
- description = inline if eq else value_of(option)
elif option == "--cwd":
cwd = inline if eq else value_of(option)
elif option == "--replace":
@@ -276,7 +269,7 @@ def parse_add_argv(argv: list[str]) -> tuple[list[dict[str, Any]], bool]:
index += 1
if json_text is not None:
- if positionals or command is not None or env or headers or description or cwd:
+ if positionals or command is not None or env or headers or cwd:
raise McpHubError("usage", "--json-stdin takes no other server arguments.", usage=True)
return parse_provider_json(json_text), replace
if not positionals:
@@ -309,7 +302,7 @@ def parse_add_argv(argv: list[str]) -> tuple[list[dict[str, Any]], bool]:
server["env"] = env
if cwd is not None:
server["cwd"] = cwd
- return [definition_from_provider(name, server, description=description)], replace
+ return [definition_from_provider(name, server)], replace
def provider_entry(definition: dict[str, Any]) -> dict[str, Any]:
diff --git a/core/mcp_hub/native.py b/core/mcp_hub/native.py
index 61e4a818f..4cce58c8c 100644
--- a/core/mcp_hub/native.py
+++ b/core/mcp_hub/native.py
@@ -190,15 +190,15 @@ def _native_enabled(source: str, entry: dict[str, Any]) -> bool:
return entry.get("enabled") is not False
-def _from_native(source: str, name: str, entry: dict[str, Any], path: Path, description: Optional[str]) -> dict[str, Any]:
+def _from_native(source: str, name: str, entry: dict[str, Any], path: Path) -> dict[str, Any]:
server = _READERS[source](entry)
cwd = server.get("cwd")
if isinstance(cwd, str) and cwd.strip():
server["cwd"] = _resolve_cwd(path, cwd)
- return definition_from_provider(name, server, description=description)
+ return definition_from_provider(name, server)
-def read_all(descriptions: Optional[dict[str, str]] = None) -> dict[str, NativeServer]:
+def read_all() -> dict[str, NativeServer]:
"""The union of native servers; the first source holding a name is canonical.
A file that cannot be parsed is skipped; one bad entry only marks that server.
@@ -206,7 +206,6 @@ def read_all(descriptions: Optional[dict[str, str]] = None) -> dict[str, NativeS
backend's own off switch. Spawn isolation still disables remaining names.
"""
- descriptions = descriptions or {}
servers: dict[str, NativeServer] = {}
for source in SOURCES:
try:
@@ -223,7 +222,7 @@ def read_all(descriptions: Optional[dict[str, str]] = None) -> dict[str, NativeS
raise McpHubError("invalid_definition", f"{source} entry {name!r} is not an object.")
if not _native_enabled(source, entry):
continue
- definition = _from_native(source, str(name), entry, path, descriptions.get(str(name)))
+ definition = _from_native(source, str(name), entry, path)
servers[str(name)] = NativeServer(
str(name), source, path, definition, None, has_cwd="cwd" in entry
)
diff --git a/core/mcp_hub/prompt.py b/core/mcp_hub/prompt.py
index 72d7a42fc..dd6ac0537 100644
--- a/core/mcp_hub/prompt.py
+++ b/core/mcp_hub/prompt.py
@@ -3,37 +3,40 @@
from __future__ import annotations
import logging
-from typing import Optional
+from core.managed_skills import catalog_page_of
from core.mcp_hub import repository
from core.mcp_hub.definition import normalize_description
from core.prompt_registry import RenderedPromptBlock, render_prompt_block
logger = logging.getLogger(__name__)
-PROMPT_SERVER_LIMIT = 50
+def server_row(item: dict) -> str:
+ """``- <name>: <description>``, or ``- <name>`` when the server reported none."""
+ description = normalize_description(item.get("description"))
+ return f"- {item['name']}: {description}" if description else f"- {item['name']}"
-def build_mcp_prompt_block() -> Optional[RenderedPromptBlock]:
- """One line per enabled, generated package; omitted when there is none.
+
+def build_mcp_prompt_blocks() -> list[RenderedPromptBlock]:
+ """Page 1 of enabled, generated packages, paged like the Skills catalog; empty when there is none.
The index grants nothing: every call rechecks the published revision at the owner.
"""
- from vibe.i18n import t
-
try:
packages = repository.list_packages()
except Exception:
logger.warning("MCP prompt index unavailable", exc_info=True)
- return None
- if not packages:
- return None
- rows = [
- f"- {item['name']}: {normalize_description(item.get('description')) or t('mcp.genericDescription')}"
- for item in packages[:PROMPT_SERVER_LIMIT]
- ]
- omitted = len(packages) - PROMPT_SERVER_LIMIT
- if omitted > 0:
- rows.append(f"- … {omitted} more; run `vibe mcp --list`.")
- return render_prompt_block("mcp-capabilities-prompt", server_rows="\n".join(rows))
+ return []
+ entries, next_page = catalog_page_of(packages, server_row, 1)
+ if not entries:
+ return []
+ blocks = [render_prompt_block("mcp-capabilities-prompt")]
+ if next_page is not None:
+ blocks.append(render_prompt_block("mcp-pagination-prompt"))
+ blocks.append(render_prompt_block("mcp-catalog", server_rows="\n".join(server_row(item) for item in entries)))
+ if next_page is not None:
+ notice = render_prompt_block("mcp-more-notice", next_page=next_page)
+ blocks.append(RenderedPromptBlock(notice.module_id, "\n" + notice.text))
+ return blocks
diff --git a/core/mcp_hub/repository.py b/core/mcp_hub/repository.py
index a26b511b7..5b85a9f60 100644
--- a/core/mcp_hub/repository.py
+++ b/core/mcp_hub/repository.py
@@ -366,7 +366,7 @@ def summarize(name: str, servers: Optional[dict[str, native.NativeServer]] = Non
"name": name,
"source": source,
"sourcePath": source_path,
- "description": manifest.get("description") or (definition.get("description") if isinstance(definition, dict) else "") or "",
+ "description": manifest.get("description") or "",
"transport": transport.get("type") if isinstance(transport, dict) else None,
"command": command,
"url": url,
diff --git a/core/mcp_hub/runtime.py b/core/mcp_hub/runtime.py
index 1c34bf312..dbcdb14fa 100644
--- a/core/mcp_hub/runtime.py
+++ b/core/mcp_hub/runtime.py
@@ -24,7 +24,7 @@ import anyio
from core.mcp_hub import commands as mcp_commands
from core.mcp_hub import native, repository
-from core.mcp_hub.definition import HTTP, STDIO, definition_from_provider
+from core.mcp_hub.definition import HTTP, STDIO, definition_from_provider, normalize_description
from core.mcp_hub.errors import McpHubError
logger = logging.getLogger(__name__)
@@ -107,6 +107,18 @@ async def _enter_client(definition: dict[str, Any], stack: contextlib.AsyncExitS
return await stack.enter_async_context(_client_for(definition, stack, mode="legacy"))
+def _first_sentence(text: Optional[str]) -> Optional[str]:
+ """The server instructions up to the first sentence end or line break."""
+
+ if not isinstance(text, str):
+ return None
+ text = text.strip()
+ ends = [index + 1 for index in (text.find(". "), text.find(".\n"), text.find("。")) if index >= 0]
+ if "\n" in text:
+ ends.append(text.index("\n"))
+ return text[: min(ends)] if ends else text
+
+
async def _list_all_tools(client) -> list:
tools: list = []
cursor: Optional[str] = None
@@ -397,7 +409,7 @@ class McpRuntime:
async def _add(self, payload: dict[str, Any]) -> bytes:
replace = payload.get("replace") is True
definitions = [
- definition_from_provider(item.get("name"), item.get("server"), description=item.get("description"))
+ definition_from_provider(item.get("name"), item.get("server"))
for item in payload.get("servers") or []
]
if not definitions:
@@ -462,7 +474,6 @@ class McpRuntime:
transport["cwd"] = repository.default_cwd()
return {
"name": definition.get("name"),
- "description": definition.get("description") or "",
"transport": transport,
}
@@ -528,7 +539,7 @@ class McpRuntime:
if remaining <= 0:
raise TimeoutError
with anyio.fail_after(remaining):
- tools, server_info = await self._discover(snapshot)
+ tools, server_info, instructions = await self._discover(snapshot)
except TimeoutError:
if unlist_on_failure:
await asyncio.to_thread(repository.unlist, name)
@@ -544,7 +555,7 @@ class McpRuntime:
finally:
if acquired:
self.release_stdio_slot()
- revision = await asyncio.to_thread(self._publish, name, snapshot, definition, tools, server_info)
+ revision = await asyncio.to_thread(self._publish, name, snapshot, definition, tools, server_info, instructions)
await self._retire_package(name, keep_revision=revision)
return _dumps({"ok": True, "name": name, "revision": revision, "toolCount": len(tools)})
@@ -598,13 +609,13 @@ class McpRuntime:
return list(await asyncio.gather(*(one(name) for name in sorted(names))))
@staticmethod
- async def _discover(snapshot: dict[str, Any]) -> tuple[list, Any]:
+ async def _discover(snapshot: dict[str, Any]) -> tuple[list, Any, Optional[str]]:
async with contextlib.AsyncExitStack() as stack:
client = await _enter_client(snapshot, stack)
- return await _list_all_tools(client), client.server_info
+ return await _list_all_tools(client), client.server_info, client.instructions
@staticmethod
- def _publish(name, snapshot, definition, tools, server_info) -> str:
+ def _publish(name, snapshot, definition, tools, server_info, instructions=None) -> str:
descriptors, diagnostics, seen = [], [], set()
for tool in tools:
descriptor = tool.model_dump(mode="json", by_alias=True, exclude_none=True)
@@ -619,7 +630,9 @@ class McpRuntime:
descriptors.append(descriptor)
descriptors.sort(key=lambda item: item["name"])
manifest: dict[str, Any] = {
- "description": definition.get("description") or "",
+ "description": normalize_description(
+ getattr(server_info, "description", None) or _first_sentence(instructions)
+ ),
"generatedAt": datetime.now(timezone.utc).isoformat(timespec="seconds"),
}
version = getattr(server_info, "version", None)
diff --git a/core/prompt_registry.py b/core/prompt_registry.py
index 7c3593351..4c07835d1 100644
--- a/core/prompt_registry.py
+++ b/core/prompt_registry.py
@@ -88,7 +88,10 @@ PROMPT_MODULES: tuple[PromptModule, ...] = (
PromptModule("harness-routing-prompt", "Harness Routing Prompt", "harness.md", leading_newlines=1, trailing_newlines=1),
PromptModule("harness-agents-prompt", "Harness Agents Prompt", "harness-agents.md", placeholders=("enabled_agents_rows",)),
PromptModule("preferences-context-prompt", "Preferences and Project Context Prompt", "preferences-context.md", leading_newlines=1, trailing_newlines=1, placeholders=("preferences_path", "platform")),
- PromptModule("mcp-capabilities-prompt", "MCP Capabilities", "mcp.md", leading_newlines=1, trailing_newlines=1, placeholders=("server_rows",)),
+ PromptModule("mcp-capabilities-prompt", "MCP Capabilities", "mcp.md", leading_newlines=1, trailing_newlines=1),
+ PromptModule("mcp-pagination-prompt", "MCP Discovery Pagination", "mcp-pagination.md", trailing_newlines=1),
+ PromptModule("mcp-catalog", "Available MCP Servers", "mcp-catalog.md", trailing_newlines=1, placeholders=("server_rows",)),
+ PromptModule("mcp-more-notice", "MCP Next Page", "mcp-more.md", trailing_newlines=1, placeholders=("next_page",)),
PromptModule("skills-manual-prompt", "Explicit Skill Requests", "skills-manual.md", leading_newlines=2),
PromptModule("skills-catalog-heading", "Available Skills Heading", "skills-catalog-heading.md", leading_newlines=2, trailing_newlines=1),
PromptModule("skills-pagination-prompt", "Skills Discovery Pagination", "skills-pagination.md", trailing_newlines=1),
diff --git a/core/prompts/mcp-catalog.md b/core/prompts/mcp-catalog.md
new file mode 100644
index 000000000..82cabfc01
--- /dev/null
+++ b/core/prompts/mcp-catalog.md
@@ -0,0 +1 @@
+{server_rows}
diff --git a/core/prompts/mcp-more.md b/core/prompts/mcp-more.md
new file mode 100644
index 000000000..8c91a189f
--- /dev/null
+++ b/core/prompts/mcp-more.md
@@ -0,0 +1 @@
+More servers are available. Run `vibe mcp --list --page {next_page}` to view more.
diff --git a/core/prompts/mcp-pagination.md b/core/prompts/mcp-pagination.md
new file mode 100644
index 000000000..caff3fadd
--- /dev/null
+++ b/core/prompts/mcp-pagination.md
@@ -0,0 +1 @@
+Use `vibe mcp --list --page 2` only when more discovery is useful; ordinary tasks do not require scanning every page.
diff --git a/core/prompts/mcp.md b/core/prompts/mcp.md
index d715b52a3..13cddc5b4 100644
--- a/core/prompts/mcp.md
+++ b/core/prompts/mcp.md
@@ -3,9 +3,7 @@
Use `vibe mcp <server> --list` to discover available tools.
Use `vibe mcp <server> <tool> --help` to inspect arguments before calling.
Call tools with `vibe mcp <server> <tool> [arguments]`.
-Help and lists read local generated definitions; tool calls access the MCP server.
+Help and lists read local snapshots; tool calls access the MCP server.
+Only call servers listed here or returned by `vibe mcp --list`; do not guess server names.
Available servers:
-{server_rows}
-
-List all servers: `vibe mcp --list`.
diff --git a/core/system_prompt_injection.py b/core/system_prompt_injection.py
index 6838aa045..95b62008c 100644
--- a/core/system_prompt_injection.py
+++ b/core/system_prompt_injection.py
@@ -247,11 +247,9 @@ def build_system_prompt_blocks(
context,
fallback_platform=fallback_platform,
))
- from core.mcp_hub.prompt import build_mcp_prompt_block
+ from core.mcp_hub.prompt import build_mcp_prompt_blocks
- mcp_block = build_mcp_prompt_block()
- if mcp_block is not None:
- blocks.append(mcp_block)
+ blocks.extend(build_mcp_prompt_blocks())
if skills is not None:
from core.managed_skills import render_skill_catalog_blocks
diff --git a/docs/MCP_HUB.md b/docs/MCP_HUB.md
index 049e8ba41..ef9f0400b 100644
--- a/docs/MCP_HUB.md
+++ b/docs/MCP_HUB.md
@@ -61,10 +61,11 @@ Env and header values are stored as given. URLs with `user:pass@` are rejected;
## Call tools
-Agents see registered servers in their system prompt and discover tools on demand:
+Agents see registered servers in their system prompt and discover tools on demand. Each server's line shows the description the server itself reports, or else the first sentence of its instructions, captured when Avibe refreshes it; a server with neither is listed by name only. The list is paged like Skills (25 servers per page); the prompt shows page 1 and `vibe mcp --list --page N` shows the rest:
```bash
vibe mcp --list
+vibe mcp --list --page 2
vibe mcp docs --list
vibe mcp docs search --help
vibe mcp docs search --query 'async Python' --limit 5
diff --git a/docs/plans/mcp-hub-mvp.md b/docs/plans/mcp-hub-mvp.md
index 3542695e3..1c63b0906 100644
--- a/docs/plans/mcp-hub-mvp.md
+++ b/docs/plans/mcp-hub-mvp.md
@@ -55,20 +55,19 @@ The shared system prompt gets a short discovery index (outside `core/managed_ski
Use `vibe mcp <server> --list` to discover available tools.
Use `vibe mcp <server> <tool> --help` to inspect arguments before calling.
Call tools with `vibe mcp <server> <tool> [arguments]`.
-Help and lists read local generated definitions; tool calls access the MCP server.
+Help and lists read local snapshots; tool calls access the MCP server.
+Only call servers listed here or returned by `vibe mcp --list`; do not guess server names.
Available servers:
- context7: Find current library documentation and code examples.
- github: Work with GitHub repositories, issues, and pull requests.
-
-List all servers: `vibe mcp --list`.
```
- One line per package, sorted by name; description sanitized to one line, max 160 chars.
-- Description: from the published snapshot's manifest (user-provided at add/refresh, else a localized generic string). Server-provided text is not used. There is one snapshot per server; there are no pending edits.
-- List at most 50 servers; if more exist, append the omitted count and `vibe mcp --list`.
+- Description: the server-reported `serverInfo.description`, else the first sentence of the initialize `instructions` (cut at the first `. `, `.\n`, `。` or line break), sanitized and frozen in the published snapshot's manifest at refresh, never read live (owner decision). There is no user-provided description and no fallback text: a server with neither is listed as `- <server>`. There is one snapshot per server; there are no pending edits.
+- Paged exactly like the Skills catalog (shared `catalog_page_of`): each page holds at most 25 rows (`CATALOG_PAGE_SIZE`) within `CATALOG_PAGE_MAX_BYTES`, always at least one. The prompt shows page 1; when more exist it adds a hint before the rows ("Use `vibe mcp --list --page 2` only when more discovery is useful; ordinary tasks do not require scanning every page.") and ends with "More servers are available. Run `vibe mcp --list --page {next_page}` to view more." `vibe mcp --list --page N` prints that page with the same rows and notice; `--format json` adds `nextPage`.
- No tool names, schemas, URLs, commands, credentials or management commands.
-- The block has two fixed parts: stable shared instructions (examples must stay parser-valid), then one `<server>: <description>` line per package, where `<server>` is the exact CLI selector.
+- The block has two fixed parts: stable shared instructions (examples must stay parser-valid), then one `<server>: <description>` line per package (`<server>` alone when the server reports no description), where `<server>` is the exact CLI selector.
- Disable/remove takes effect on the next prompt build; new calls are rejected immediately even if a running turn still sees the old list.
- The index grants nothing: every call rechecks the published revision at the owner.
@@ -128,7 +127,7 @@ vibe mcp docs --refresh
vibe mcp docs --remove
```
-- `vibe mcp-add` uses the Claude Code `mcp add` subset plus `--description`, `--cwd`, `--replace`, `--json-stdin`. It writes only the Avibe store, then refreshes that name; the call returns after refresh.
+- `vibe mcp-add` uses the Claude Code `mcp add` subset plus `--cwd`, `--replace`, `--json-stdin`. It writes only the Avibe store, then refreshes that name; the call returns after refresh.
- `vibe mcp-discover` runs one full pass (joins an in-flight pass) and prints registered / failed + reason. Controller startup runs the same pass in the background, off the controller loop.
- Names: empty, `.`/`..`, NUL, `/`/`\\` rejected. Management verbs are not reserved names.
- Owner-only: mcp-add, mcp-discover, `--refresh`, `--remove`. Editor: list/help/call.
diff --git a/tests/fixtures/mcp_echo_server.py b/tests/fixtures/mcp_echo_server.py
index f3ba4f3cf..c73527c34 100644
--- a/tests/fixtures/mcp_echo_server.py
+++ b/tests/fixtures/mcp_echo_server.py
@@ -6,7 +6,7 @@ import time
from mcp.server.mcpserver import MCPServer
-server = MCPServer("avibe-echo", version="0.1.0")
+server = MCPServer("avibe-echo", description="Echo tools", version="0.1.0")
@server.tool(description="Echo text back, optionally repeated.")
diff --git a/tests/test_mcp_hub_native.py b/tests/test_mcp_hub_native.py
index 9a6628eb2..d31092f25 100644
--- a/tests/test_mcp_hub_native.py
+++ b/tests/test_mcp_hub_native.py
@@ -72,7 +72,7 @@ def test_hub_reads_native_union_without_listing_unpublished(native_files):
def test_add_writes_avibe_store_and_remove_hides_native(native_files, runtime):
claude, _codex, _opencode = native_files
before = claude.read_bytes()
- new = {"name": "fresh", "server": {"command": "/nonexistent/mcp-fresh"}, "description": "Fresh"}
+ new = {"name": "fresh", "server": {"command": "/nonexistent/mcp-fresh"}}
result = _run(runtime, "add", {"servers": [new]})
assert result["ok"] is False # http fixture is unreachable; add rolls back
assert repository.read_avibe_definition("fresh") is None
@@ -208,7 +208,6 @@ def test_native_delete_hides_and_may_drop_artifacts(native_files):
definition = {
"schemaVersion": 1,
"name": "docs",
- "description": "Search",
"transport": {"type": "streamable_http", "url": "https://example.invalid/mcp", "headers": {}},
}
tool = {"name": "search", "description": "", "inputSchema": {"type": "object", "properties": {}}}
diff --git a/tests/test_mcp_hub_runtime.py b/tests/test_mcp_hub_runtime.py
index d43d19a88..54f898868 100644
--- a/tests/test_mcp_hub_runtime.py
+++ b/tests/test_mcp_hub_runtime.py
@@ -15,7 +15,7 @@ import pytest
from core.mcp_hub import repository
from core.mcp_hub import runtime as mcp_runtime
-from core.mcp_hub.prompt import build_mcp_prompt_block
+from core.mcp_hub.prompt import build_mcp_prompt_blocks
from core.mcp_hub.runtime import McpRuntime
from tests.ui_server_test_helpers import save_config
@@ -23,6 +23,10 @@ from tests.ui_server_test_helpers import save_config
FIXTURE = str(Path(__file__).parent / "fixtures" / "mcp_echo_server.py")
+def _prompt() -> str:
+ return "".join(block.text for block in build_mcp_prompt_blocks())
+
+
def _run(runtime: McpRuntime, operation: str, payload: dict) -> dict:
status, body = asyncio.run(runtime.submit(operation, payload))
assert status == 200
@@ -30,7 +34,7 @@ def _run(runtime: McpRuntime, operation: str, payload: dict) -> dict:
def _server(command: str = sys.executable) -> dict:
- return {"name": "echo", "server": {"command": command, "args": [FIXTURE]}, "description": "Echo tools"}
+ return {"name": "echo", "server": {"command": command, "args": [FIXTURE]}}
@pytest.fixture
@@ -79,7 +83,7 @@ def test_batch_add_registers_neighbors_and_rolls_back_the_failure(runtime):
good = _server()
bad = {"name": "github", "server": {"command": "/nonexistent/mcp-github"}}
- other = {"name": "zeta", "server": {"command": sys.executable, "args": [FIXTURE]}, "description": "Z"}
+ other = {"name": "zeta", "server": {"command": sys.executable, "args": [FIXTURE]}}
result = _run(runtime, "add", {"servers": [good, bad, other]})
names = {item["name"] for item in result["added"]}
failed = {item["name"]: item["error"] for item in result["failed"]}
@@ -141,7 +145,6 @@ def test_failed_readd_of_hidden_native_stays_hidden(runtime):
def test_failed_explicit_refresh_unlists_the_server(generated):
repository.write_avibe_definition({
"name": "echo",
- "description": "Echo tools",
"transport": {"type": "stdio", "command": "/nonexistent/mcp-echo", "args": [FIXTURE]},
})
result = _run(generated, "refresh", {"name": "echo", "waitStdio": True})
@@ -152,7 +155,6 @@ def test_failed_explicit_refresh_unlists_the_server(generated):
def test_failed_discover_unlists_previous_revision(generated):
repository.write_avibe_definition({
"name": "echo",
- "description": "Echo tools",
"transport": {"type": "stdio", "command": "/nonexistent/mcp-echo", "args": [FIXTURE]},
})
result = _run(generated, "discover", {})
@@ -196,7 +198,6 @@ def test_native_definition_change_is_not_unchanged_until_published(runtime):
pasted = {
"name": "echo",
"server": {"command": sys.executable, "args": [FIXTURE, "--other"]},
- "description": "Echo tools",
}
blocked = _run(runtime, "add", {"servers": [pasted]})
assert blocked["ok"] is False
@@ -229,7 +230,6 @@ def test_explicit_cwd_difference_is_exists_not_unchanged(generated):
same_command = {
"name": "echo",
"server": {"command": sys.executable, "args": [FIXTURE], "cwd": "/tmp/mcp-other-cwd"},
- "description": "Echo tools",
}
result = _run(generated, "add", {"servers": [same_command]})
assert result["ok"] is False
@@ -317,7 +317,7 @@ def test_future_format_revision_is_not_listed(generated):
manifest = repository.package_dir("echo") / "revisions" / published["revision"] / "manifest.json"
manifest.write_text(json.dumps({"formatVersion": 99}))
assert "echo" not in {item["name"] for item in repository.list_packages()}
- assert build_mcp_prompt_block() is None
+ assert _prompt() == ""
def test_cli_list_and_help_work_with_the_owner_down(generated, capsys):
@@ -325,7 +325,7 @@ def test_cli_list_and_help_work_with_the_owner_down(generated, capsys):
generated.stop()
assert mcp_cli.main(["--list"]) == 0
- assert "echo Echo tools" in capsys.readouterr().out
+ assert "- echo: Echo tools" in capsys.readouterr().out
assert mcp_cli.main(["echo", "--list"]) == 0
assert "echo Echo text back" in capsys.readouterr().out
assert mcp_cli.main(["echo", "echo", "--help"]) == 0
@@ -388,7 +388,7 @@ def test_mcp_add_does_not_treat_json_stdin_after_separator_as_avibe_option(monke
def test_prompt_index_lists_enabled_servers_and_its_examples_parse(generated, capsys, monkeypatch):
from vibe import mcp_cli
- text = build_mcp_prompt_block().text
+ text = _prompt()
assert "- echo: Echo tools" in text
examples = re.findall(r"`(vibe mcp[^`]*)`", text)
assert examples
@@ -402,6 +402,55 @@ def test_prompt_index_lists_enabled_servers_and_its_examples_parse(generated, ca
+def _publish_docs(name="docs", instructions=None, **server_info):
+ from types import SimpleNamespace
+
+ definition = {"name": name, "transport": {"type": "streamable_http", "url": "https://example.invalid/mcp"}}
+ repository.write_avibe_definition(definition)
+ McpRuntime._publish(name, definition, definition, [], SimpleNamespace(version=None, **server_info), instructions)
+
+
+ ("server_info", "instructions", "line"),
+ [
+ ({"description": "Search\n the\tdocs"}, "Ignored. Text", "- docs: Search the docs"),
+ ({"description": "x" * 200}, None, "- docs: " + "x" * 160),
+ ({}, "Look up docs. Then cite them.", "- docs: Look up docs."),
+ ({}, "Look up docs\nand cite them.", "- docs: Look up docs"),
+ ({}, "查询文档。然后引用。", "- docs: 查询文档。"),
+ ({"title": "Docs"}, None, "- docs"),
+ ],
+)
+def test_prompt_line_uses_server_description_then_first_instruction_sentence(runtime, server_info, instructions, line):
+ _publish_docs(instructions=instructions, **server_info)
+ assert line in _prompt().splitlines()
+
+
+def test_prompt_and_list_page_like_the_skills_catalog(runtime, capsys, monkeypatch):
+ from core.managed_skills import CATALOG_PAGE_SIZE
+ from vibe import mcp_cli
+
+ for index in range(CATALOG_PAGE_SIZE + 1):
+ _publish_docs(f"s{index:02d}")
+ text = _prompt()
+ lines = text.splitlines()
+ assert sum(line.startswith("- s") for line in lines) == CATALOG_PAGE_SIZE
+ assert "Use `vibe mcp --list --page 2` only when more discovery is useful" in text
+ assert "More servers are available. Run `vibe mcp --list --page 2` to view more." in lines
+ monkeypatch.setattr(mcp_cli, "_admit", lambda _floor: None)
+ for example in sorted(set(re.findall(r"`(vibe mcp --list[^`]*)`", text))):
+ assert mcp_cli.main(shlex.split(example)[2:]) == 0, example
+ capsys.readouterr()
+ assert mcp_cli.main(["--list", "--page", "2", "--format", "json"]) == 0
+ second = json.loads(capsys.readouterr().out)
+ assert [item["name"] for item in second["servers"]] == [f"s{CATALOG_PAGE_SIZE:02d}"]
+ assert second["nextPage"] is None
+ assert mcp_cli.main(["--list"]) == 0
+ first = capsys.readouterr().out
+ assert "- s00" in first and "Run `vibe mcp --list --page 2` to view more." in first
+ assert mcp_cli.main(["--list", "--page", "0"]) == 2
+
+
@pytest.mark.parametrize(("argv", "allowed"), [(["--list"], True), (["echo", "--refresh"], False)])
def test_editor_discovers_but_cannot_manage(generated, argv, allowed, capsys):
from vibe import mcp_cli
diff --git a/tests/test_prompt_render_export.py b/tests/test_prompt_render_export.py
index 79465dbf8..2bbb1fb20 100644
--- a/tests/test_prompt_render_export.py
+++ b/tests/test_prompt_render_export.py
@@ -121,7 +121,8 @@ def _environment(monkeypatch, history="managed", skill_mode="pages"):
for name in names
] if skill_mode != "empty" else []
monkeypatch.setattr(managed_skills, "resolve_skills", lambda *_args, **_kwargs: skills)
- monkeypatch.setattr(mcp_repository, "list_packages", lambda: [{"name": "docs", "description": "Docs"}])
+ servers = [{"name": f"docs-{index:02}", "description": "Docs"} for index in range(26 if skill_mode == "pages" else 1)]
+ monkeypatch.setattr(mcp_repository, "list_packages", lambda: servers)
@pytest.mark.parametrize("backend,history,skill_mode", itertools.product(
@@ -556,6 +557,9 @@ def test_approved_guidance_changes_preserve_all_other_injection_bytes(monkeypatc
"codex-skill-reuse",
# New MCP Hub discovery index (docs/plans/mcp-hub-mvp.md §3).
"mcp-capabilities-prompt",
+ "mcp-catalog",
+ "mcp-pagination-prompt",
+ "mcp-more-notice",
}
for backend, history, skill_mode in itertools.product(
("claude", "codex", "opencode"), ("off", "managed", "self-managed"), ("empty", "manual", "pages"),
diff --git a/vibe/i18n/en.json b/vibe/i18n/en.json
index 578d67fbc..56440418f 100644
--- a/vibe/i18n/en.json
+++ b/vibe/i18n/en.json
@@ -1795,8 +1795,5 @@
"unsupported": "The reference image {path} is {mime}, which cannot be sent."
}
}
- },
- "mcp": {
- "genericDescription": "Tools from an MCP server."
}
}
diff --git a/vibe/i18n/zh.json b/vibe/i18n/zh.json
index 02b4af02a..7dae1fbee 100644
--- a/vibe/i18n/zh.json
+++ b/vibe/i18n/zh.json
@@ -1795,8 +1795,5 @@
"unsupported": "参考图片 {path} 是 {mime},无法发送。"
}
}
- },
- "mcp": {
- "genericDescription": "来自 MCP 服务器的工具。"
}
}
diff --git a/vibe/mcp_api.py b/vibe/mcp_api.py
index 66b06408a..5b0ca90fe 100644
--- a/vibe/mcp_api.py
+++ b/vibe/mcp_api.py
@@ -39,7 +39,7 @@ async def _owner(operation: str, payload: dict[str, Any]) -> dict[str, Any]:
def _servers_payload(definitions: list[dict[str, Any]]) -> list[dict[str, Any]]:
return [
- {"name": item["name"], "server": provider_entry(item), "description": item.get("description")}
+ {"name": item["name"], "server": provider_entry(item)}
for item in definitions
]
diff --git a/vibe/mcp_cli.py b/vibe/mcp_cli.py
index 55f782b69..e56f9ccbb 100644
--- a/vibe/mcp_cli.py
+++ b/vibe/mcp_cli.py
@@ -20,7 +20,7 @@ from core.mcp_hub.errors import McpHubError
USAGE = """\
usage:
- vibe mcp --list [--format json]
+ vibe mcp --list [--page N] [--format json]
vibe mcp <server> --list [--format json]
vibe mcp <server> --refresh
vibe mcp <server> --remove
@@ -31,7 +31,7 @@ usage:
management (Owner):
vibe mcp-add [--transport stdio|http] [--env KEY=VALUE ...] [--header 'Name: value' ...]
- [--description TEXT] [--cwd DIR] [--replace] <name> -- <command> [args...]
+ [--cwd DIR] [--replace] <name> -- <command> [args...]
vibe mcp-add --transport http <name> <url>
vibe mcp-add --json-stdin [--replace]
vibe mcp-discover
@@ -133,17 +133,29 @@ def _format_json(options: list[str], allowed: set[str]) -> bool:
def _root_list(argv: list[str]) -> int:
+ from core.managed_skills import catalog_page_of
+ from core.mcp_hub.prompt import server_row
+
+ page = 1
+ if "--page" in argv:
+ position = argv.index("--page")
+ value = argv[position + 1] if position + 1 < len(argv) else ""
+ if not value.isdigit() or int(value) < 1:
+ raise McpHubError("usage", "--page takes a positive integer.", usage=True)
+ page = int(value)
+ argv = argv[:position] + argv[position + 2 :]
as_json = _format_json(argv, {"--list"})
- packages = repository.list_packages()
+ entries, next_page = catalog_page_of(repository.list_packages(), server_row, page)
if as_json:
- print(json.dumps({"servers": packages}, ensure_ascii=False, indent=2))
+ print(json.dumps({"servers": list(entries), "nextPage": next_page}, ensure_ascii=False, indent=2))
return 0
- if not packages:
+ if not entries:
print("No MCP servers.")
return 0
- for item in packages:
- extra = f" [{item.get('source') or 'avibe'}]" if item.get("source") else ""
- print(f"{item['name']} {escape(item.get('description') or '')}{extra}".rstrip())
+ for item in entries:
+ print(escape(server_row(item)))
+ if next_page is not None:
+ print(f"\nMore servers are available. Run `vibe mcp --list --page {next_page}` to view more.")
print("\nNext: vibe mcp <server> --list")
return 0
@@ -200,7 +212,7 @@ def _add(args: list[str]) -> int:
payload = {
"replace": replace,
"servers": [
- {"name": item["name"], "server": provider_entry(item), "description": item.get("description")}
+ {"name": item["name"], "server": provider_entry(item)}
for item in definitions
],
}