Skip to content

Conversation

@brendan-kellam
Copy link
Contributor

@brendan-kellam brendan-kellam commented Jan 28, 2026

This PR adds the "ask_codebase" tool to the MCP server, which allows agents to invoke the Ask Sourcebot agent to perform codebase exploration on its behalf. This is still very much a experiment, but our hypothesis on why using the subagent over using the search tool directly is the following:

  • the parent agent's context window does not get impacted
  • the subagent is optimized on code retrieval across multiple repos.
  • all subagent sessions have a associated web url to the same Ask Sourcebot interface.

Summary by CodeRabbit

  • New Features

    • Blocking "ask codebase" workflow that returns a Markdown answer, session link, and model metadata.
    • Endpoint to list available language models.
  • Improvements

    • Unified repository listing tool and consolidated code-search options (query, regex, repo/language/filepath filters, ref, case sensitivity).
    • Streamlined agent prompt/file-source handling and added telemetry events for message sends and tool usage.
  • Documentation

    • Updated MCP docs and README for new tools and search parameters.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 28, 2026

Walkthrough

Adds MCP client APIs for listing language models and asking the codebase; introduces a blocking chat endpoint that runs an agent synchronously; consolidates repo-listing/search tooling into a single listRepos flow; refactors agent prompt/file-source resolution to use selectedRepos and updates UI tooling and telemetry.

Changes

Cohort / File(s) Summary
MCP client & schemas
packages/mcp/src/client.ts, packages/mcp/src/index.ts, packages/mcp/src/schemas.ts, packages/mcp/src/types.ts
Added askCodebase and listLanguageModels client APIs plus associated request/response schemas and types (askCodebaseRequestSchema, askCodebaseResponseSchema, languageModelInfoSchema, listLanguageModelsResponseSchema, and inferred types).
Blocking chat API
packages/web/src/app/api/(server)/chat/blocking/route.ts
New POST /api/chat/blocking handler: validates request, authenticates, selects model, creates chat/message, runs the agent stream to completion (draining), persists final messages, extracts assistant markdown answer, builds chat URL, and returns { answer, chatId, chatUrl, languageModel }.
Models route
packages/web/src/app/api/(server)/models/route.ts
New GET /api/models route that returns configured language model metadata (used by MCP client listLanguageModels).
Chat streaming / agent surface
packages/web/src/app/api/(server)/chat/route.ts, packages/web/src/features/chat/agent.ts
Exported createMessageStream with an onFinish callback; replaced searchScopeRepoNames with selectedRepos; inlined/rewrote prompt and file-source resolution (new createPrompt / runtime file source handling); normalized tool outputs and source wiring.
Repo listing API & route
packages/web/src/app/api/(server)/repos/listReposApi.ts, packages/web/src/app/api/(server)/repos/route.ts
Added listRepos service (paging/filtering/mapping) and refactored repos route to delegate to it, centralizing repo query logic and response mapping.
Tools surface & search changes
packages/web/src/features/chat/tools.ts, packages/web/src/features/chat/constants.ts, packages/web/src/features/chat/types.ts
Removed searchReposTool/listAllReposTool; added listReposTool; redesigned createCodeSearchTool input schema to explicit parameters (query, useRegex, filterByRepos, filterByLanguages, filterByFilepaths, caseSensitive, ref, limit) and added DEFAULT_SEARCH_LIMIT.
UI components
packages/web/src/features/chat/components/chatThread/detailsCard.tsx, packages/web/src/features/chat/components/chatThread/tools/listReposToolComponent.tsx, packages/web/src/features/chat/components/chatThread/tools/searchCodeToolComponent.tsx, packages/web/src/features/chat/components/chatThread/tools/searchReposToolComponent.tsx
Renamed/removed repo tool components: ListAllReposToolComponentListReposToolComponent, removed SearchReposToolComponent, simplified search-code UI (removed manual-run query UI), updated detailsCard to use tool-listRepos.
Utilities & tests
packages/web/src/features/chat/utils.ts, packages/web/src/features/chat/utils.test.ts, packages/web/package.json
Removed buildSearchQuery and its tests; added dedent dependency for prompt formatting.
Telemetry & events
packages/web/src/features/chat/chatThread.tsx, packages/web/src/lib/posthogEvents.ts
Added captureEvent usage to emit wa_chat_message_sent with messageCount on send; extended PostHog event map with wa_chat_message_sent and wa_chat_tool_used.
Docs & MCP README
docs/docs/features/mcp-server.mdx, packages/mcp/README.md
Updated MCP docs: search_code parameters (useRegex, filters), list_repos, new ask_codebase docs and parameters, and added list_language_models doc entry.

Sequence Diagram

sequenceDiagram
    participant Client
    participant BlockingAPI as POST /api/chat/blocking
    participant Auth as Auth Layer
    participant DB as Database
    participant Agent as Agent/Streaming
    participant LLM as Language Model

    Client->>BlockingAPI: POST { query, repos, languageModel? }
    BlockingAPI->>BlockingAPI: validate request schema
    BlockingAPI->>Auth: authenticate / get context
    Auth->>DB: fetch user/config
    DB-->>Auth: user/context
    Auth-->>BlockingAPI: authenticated
    BlockingAPI->>DB: select model & create private chat + user message
    DB-->>BlockingAPI: chatId/messageId
    BlockingAPI->>Agent: invoke createMessageStream(selectedRepos, onFinish)
    Agent->>LLM: request / stream tokens (tool invocations executed as needed)
    LLM-->>Agent: streaming tokens
    Agent->>Agent: onFinish(final messages)
    Agent->>DB: persist final messages
    DB-->>Agent: persisted
    Agent-->>BlockingAPI: stream complete
    BlockingAPI->>BlockingAPI: extract markdown answer, build chatUrl
    BlockingAPI-->>Client: { answer, chatId, chatUrl, languageModel }
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related PRs

Suggested labels

sourcebot-team

Suggested reviewers

  • msukkari
🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'feat(mcp): ask subagent' is vague and does not clearly convey the main purpose of the changeset, which involves adding askCodebase and listLanguageModels APIs to the MCP server. Consider a more descriptive title such as 'feat(mcp): add askCodebase and listLanguageModels tools' or 'feat(mcp): add blocking chat API and language model selection' to better reflect the primary changes.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bkellam/subagent-SOU-268

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@msukkari
Copy link
Contributor

Can we add telemetry for MCP tool usage?

@brendan-kellam brendan-kellam force-pushed the bkellam/subagent-SOU-268 branch from d2be4cb to 59c6ebb Compare January 31, 2026 22:35
@brendan-kellam brendan-kellam changed the title [wip] MCP subagent feat(mcp): ask subagent Feb 1, 2026
@brendan-kellam brendan-kellam marked this pull request as ready for review February 1, 2026 03:38
@github-actions
Copy link
Contributor

github-actions bot commented Feb 1, 2026

@brendan-kellam your pull request is missing a changelog!

@claude
Copy link

claude bot commented Feb 1, 2026

Code Review

Security Issue Found

Missing Organization ID Filter in Repository Lookup

Location: packages/web/src/app/api/(server)/chat/blocking/route.ts lines 109-112

Issue: The repository lookup is missing the orgId filter, which could allow users to access repositories from other organizations by specifying repository names they shouldn't have access to.

Current code:

const repoDB = await prisma.repo.findFirst({
    where: {
        name: repo,
    },
});

Should be:

const repoDB = await prisma.repo.findFirst({
    where: {
        name: repo,
        orgId: org.id,
    },
});

Explanation: Without the orgId filter, a user from Organization A could potentially access repositories from Organization B by knowing or guessing repository names. The org.id is available in scope from the withOptionalAuthV2 callback (line 65) and is already used correctly when creating the chat (line 86).

References: This pattern is consistently used throughout the codebase:

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@packages/mcp/src/client.ts`:
- Around line 107-113: The docstring for the "Asks a natural language
question..." function is out of sync with the actual response shape
(implementation returns only `answer`, `chatId`, and `chatUrl`); either update
the docstring to list exactly those fields or extend the function's response to
include `sources` and `metadata`. Locate the function's return object (the
response schema that currently contains `answer`, `chatId`, `chatUrl`) and
either add `sources` and `metadata` to that object and its types, or change the
docstring text to explicitly document `answer`, `chatId`, and `chatUrl` only
(and update any exported types/interfaces used by callers).

In `@packages/web/src/app/api/`(server)/chat/blocking/route.ts:
- Around line 108-129: The loop is causing N+1 DB queries by calling
prisma.repo.findFirst for each repo; replace it with a single batched query
using prisma.repo.findMany({ where: { name: { in: repos } } }), then build a map
from repo name to the returned repo rows, detect any missing repo names and
throw the same ServiceErrorException for the first missing (or aggregate as you
prefer), and finally populate selectedSearchScopes from the mapped results using
repo.displayName ?? repo.name.split('/').pop() ?? repo.name and
repo.external_codeHostType to preserve original behavior.
🧹 Nitpick comments (3)
packages/web/src/app/api/(server)/chat/blocking/route.ts (2)

198-204: Simplify the while loop condition.

The while (true as const) syntax is unconventional. A simple while (true) achieves the same result and is more idiomatic.

♻️ Suggested simplification
 const blockStreamUntilFinish = async <T extends UIMessage<unknown, UIDataTypes, UITools>>(stream: ReadableStream<InferUIMessageChunk<T>>) => {
     const reader = stream.getReader();
-    while (true as const) {
+    while (true) {
         const { done } = await reader.read();
         if (done) break;
     }
 }

54-196: Consider adding telemetry for MCP tool usage.

A reviewer (msukkari) requested telemetry for MCP tool usage. This blocking endpoint is a primary entry point for MCP integrations and would benefit from telemetry to track usage patterns, latency, and errors.

packages/mcp/src/index.ts (1)

242-275: Consider adding error handling for askCodebase failures.

The ask_codebase tool handler directly awaits askCodebase(request) without error handling. If the blocking chat endpoint returns an error or times out, the MCP client will receive an unhandled exception. Other tools in this file also lack explicit error handling, but given the 30-60+ second blocking nature of this tool, explicit error handling would improve the user experience.

♻️ Suggested error handling
     async (request: AskCodebaseRequest) => {
-        const response = await askCodebase(request);
-
-        // Format the response with the answer and a link to the chat
-        const formattedResponse = dedent`
-        ${response.answer}
-
-        ---
-        **View full research session:** ${response.chatUrl}
-        `;
-
-        return {
-            content: [{
-                type: "text",
-                text: formattedResponse,
-            }],
-        };
+        try {
+            const response = await askCodebase(request);
+
+            // Format the response with the answer and a link to the chat
+            const formattedResponse = dedent`
+            ${response.answer}
+
+            ---
+            **View full research session:** ${response.chatUrl}
+            `;
+
+            return {
+                content: [{
+                    type: "text",
+                    text: formattedResponse,
+                }],
+            };
+        } catch (error) {
+            const message = error instanceof Error ? error.message : 'Unknown error occurred';
+            return {
+                content: [{
+                    type: "text",
+                    text: `Failed to query codebase: ${message}`,
+                }],
+                isError: true,
+            };
+        }
     }

@brendan-kellam brendan-kellam force-pushed the bkellam/subagent-SOU-268 branch from 92893a7 to e689590 Compare February 1, 2026 05:21
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@packages/mcp/src/client.ts`:
- Around line 119-124: The fetch call in askCodebase
(packages/mcp/src/client.ts) is missing the standard telemetry header; update
the headers object passed to fetch (the POST to
`${env.SOURCEBOT_HOST}/api/chat/blocking`) to include
'X-Sourcebot-Client-Source': 'mcp' alongside the existing 'Content-Type' and
optional 'X-Sourcebot-Api-Key' so MCP calls have consistent client-source
attribution.

In `@packages/web/src/app/api/`(server)/repos/listReposApi.ts:
- Around line 17-36: The totalCount calculation currently reuses the filtered
where clause including query; update the prisma.repo.count call in listReposApi
so its where only includes orgId (e.g., { orgId: org.id }) and does not apply
the name contains filter, ensuring prisma.repo.findMany retains the filtered
results while totalCount remains the unfiltered org-wide count; adjust the
Promise.all tuple that sets [repos, totalCount] accordingly (references:
prisma.repo.findMany, prisma.repo.count, repos, totalCount, org.id, query).
🧹 Nitpick comments (1)
packages/web/src/features/chat/tools.ts (1)

179-183: Redundant .optional() after .default() in Zod schema.

The limit parameter uses .default(DEFAULT_SEARCH_LIMIT) followed by .optional(). In Zod, .default() already handles undefined inputs by providing the default value. Adding .optional() afterwards changes the inferred output type to include undefined, which contradicts the intent of having a default.

♻️ Proposed fix
         limit: z
             .number()
             .default(DEFAULT_SEARCH_LIMIT)
             .describe(`Maximum number of matches to return (default: ${DEFAULT_SEARCH_LIMIT})`)
-            .optional(),
+        ,

Comment on lines +17 to +36
const [repos, totalCount] = await Promise.all([
prisma.repo.findMany({
where: {
orgId: org.id,
...(query ? {
name: { contains: query, mode: 'insensitive' },
} : {}),
},
skip,
take: perPage,
orderBy: { [orderByField]: direction },
}),
prisma.repo.count({
where: {
orgId: org.id,
...(query ? {
name: { contains: query, mode: 'insensitive' },
} : {}),
},
}),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Total count should remain unfiltered to preserve API contract.
totalCount is currently filtered by query, but the /api/repos contract expects the unfiltered org-wide count.

🔧 Suggested fix
         const [repos, totalCount] = await Promise.all([
             prisma.repo.findMany({
                 where: {
                     orgId: org.id,
                     ...(query ? {
                         name: { contains: query, mode: 'insensitive' },
                     } : {}),
                 },
                 skip,
                 take: perPage,
                 orderBy: { [orderByField]: direction },
             }),
             prisma.repo.count({
                 where: {
-                    orgId: org.id,
-                    ...(query ? {
-                        name: { contains: query, mode: 'insensitive' },
-                    } : {}),
+                    orgId: org.id,
                 },
             }),
         ]);
Based on learnings: In the Sourcebot API `/api/repos` endpoint (packages/web/src/app/api/(server)/repos/route.ts), the `X-Total-Count` header intentionally returns the total number of repositories in the collection (unfiltered count), not the count of filtered search results.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const [repos, totalCount] = await Promise.all([
prisma.repo.findMany({
where: {
orgId: org.id,
...(query ? {
name: { contains: query, mode: 'insensitive' },
} : {}),
},
skip,
take: perPage,
orderBy: { [orderByField]: direction },
}),
prisma.repo.count({
where: {
orgId: org.id,
...(query ? {
name: { contains: query, mode: 'insensitive' },
} : {}),
},
}),
const [repos, totalCount] = await Promise.all([
prisma.repo.findMany({
where: {
orgId: org.id,
...(query ? {
name: { contains: query, mode: 'insensitive' },
} : {}),
},
skip,
take: perPage,
orderBy: { [orderByField]: direction },
}),
prisma.repo.count({
where: {
orgId: org.id,
},
}),
]);
🤖 Prompt for AI Agents
In `@packages/web/src/app/api/`(server)/repos/listReposApi.ts around lines 17 -
36, The totalCount calculation currently reuses the filtered where clause
including query; update the prisma.repo.count call in listReposApi so its where
only includes orgId (e.g., { orgId: org.id }) and does not apply the name
contains filter, ensuring prisma.repo.findMany retains the filtered results
while totalCount remains the unfiltered org-wide count; adjust the Promise.all
tuple that sets [repos, totalCount] accordingly (references:
prisma.repo.findMany, prisma.repo.count, repos, totalCount, org.id, query).

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@packages/web/src/features/chat/agent.ts`:
- Around line 180-195: The template emits a `<files>` block even when files is
an empty array and places raw file.source into XML which can break tags; change
the condition from `files` to `files && files.length > 0` to avoid emitting an
empty `<files>` section, and ensure file contents are escaped when inserted
(e.g. wrap content in a CDATA block and sanitize occurrences of `]]>` by
splitting or fallback to HTML-escaping) before calling
`addLineNumbers(file.source)` so the `<file>` tags never get broken; update the
template expression that builds `${files?.map(...).join(...)}` accordingly.
🧹 Nitpick comments (2)
packages/mcp/README.md (1)

237-249: Documentation for ask_codebase looks good.

The tool description is clear and the parameters table follows the established format. One minor style nit from static analysis:

📝 Optional: Capitalize "Markdown" as a proper noun
-Ask a natural language question about the codebase. This tool uses an AI agent to autonomously search code, read files, and find symbol references/definitions to answer your question. Returns a detailed answer in markdown format with code references, plus a link to view the full research session in the Sourcebot web UI.
+Ask a natural language question about the codebase. This tool uses an AI agent to autonomously search code, read files, and find symbol references/definitions to answer your question. Returns a detailed answer in Markdown format with code references, plus a link to view the full research session in the Sourcebot web UI.
packages/web/src/features/chat/agent.ts (1)

37-65: Add a type guard when filtering resolved file sources.
filter(source !== undefined) doesn’t narrow the type, so createPrompt can still see undefined entries. A type guard keeps the array clean and avoids downstream optional handling.

♻️ Suggested update
-    ).filter((source) => source !== undefined);
+    ).filter((source): source is NonNullable<typeof source> => source !== undefined);

Comment on lines +180 to +195
${repos.length > 0 ? dedent`
<selected_repositories>
The user has explicitly selected the following repositories for analysis:
${repos.map(repo => `- ${repo}`).join('\n')}
</selected_repositories>
` : ''}

${files ? dedent`
<files>
The user has mentioned the following files, which are automatically included for analysis.

${files?.map(file => `<file path="${file.path}" repository="${file.repo}" language="${file.language}" revision="${file.revision}">
${addLineNumbers(file.source)}
</file>`).join('\n\n')}
</files>
`: ''}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Avoid emitting an empty <files> section and escape file contents.
If files is an empty array, the prompt currently claims files were provided; also raw content can break <file> tags when code contains </file> or ]]>.

🛠️ Suggested update
-    ${files ? dedent`
+    const hasFiles = (files?.length ?? 0) > 0;
+    const escapeCdata = (value: string) => value.replaceAll(']]>', ']]]]><![CDATA[>');
+
+    ${hasFiles ? dedent`
         <files>
         The user has mentioned the following files, which are automatically included for analysis.

-        ${files?.map(file => `<file path="${file.path}" repository="${file.repo}" language="${file.language}" revision="${file.revision}">
-            ${addLineNumbers(file.source)}
-            </file>`).join('\n\n')}
+        ${files!.map(file => `<file path="${file.path}" repository="${file.repo}" language="${file.language}" revision="${file.revision}"><![CDATA[${escapeCdata(addLineNumbers(file.source))}]]></file>`).join('\n\n')}
         </files>
-    `: ''}
+    `: ''}
🤖 Prompt for AI Agents
In `@packages/web/src/features/chat/agent.ts` around lines 180 - 195, The template
emits a `<files>` block even when files is an empty array and places raw
file.source into XML which can break tags; change the condition from `files` to
`files && files.length > 0` to avoid emitting an empty `<files>` section, and
ensure file contents are escaped when inserted (e.g. wrap content in a CDATA
block and sanitize occurrences of `]]>` by splitting or fallback to
HTML-escaping) before calling `addLineNumbers(file.source)` so the `<file>` tags
never get broken; update the template expression that builds
`${files?.map(...).join(...)}` accordingly.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@docs/docs/features/mcp-server.mdx`:
- Around line 220-227: Update the ask_codebase tool description to capitalize
the proper noun "Markdown" and apply the minor wording polish: change the phrase
"Returns a detailed answer in markdown format with code references, plus a link
to view the full research session in the Sourcebot web UI." to use "Markdown"
and improve clarity (e.g., "Returns a detailed answer in Markdown format with
code references and a link to view the full research session in the Sourcebot
web UI."). Ensure the change is made in the string for the ask_codebase
description and the related parameter/table text that currently contains
"markdown" so the tool name "ask_codebase" and the table entry for the return
description reflect the corrected capitalization and wording.

In `@packages/mcp/README.md`:
- Around line 248-260: The ask_codebase section's Markdown table has
alignment/formatting issues causing MARKDOWN_NNP/MD060 lint warnings; fix by
normalizing the table header and separator row (ensure the header row uses pipes
and the separator row uses matching colons/dashes like "|:---|:---:|---:|" for
intended alignment), make sure each cell is separated by pipes with consistent
whitespace, remove any stray blank lines or mismatched backticks around column
names (e.g., `query`, `repos`, `languageModel`) and ensure the surrounding
details/summary blocks are properly nested so the table renders as a single
contiguous block under the "Parameters" summary in the ask_codebase section.
🧹 Nitpick comments (1)
packages/mcp/src/index.ts (1)

275-282: Consider showing provider/displayName in the “Model used” line.
Using only model can be ambiguous across providers; a displayName or provider/model reads clearer.

💡 Example tweak
-        **Model used:** ${response.languageModel.model}
+        **Model used:** ${response.languageModel.displayName ?? `${response.languageModel.provider}/${response.languageModel.model}`}

Comment on lines +220 to +227
Ask a natural language question about the codebase. This tool uses an AI agent to autonomously search code, read files, and find symbol references/definitions to answer your question. Returns a detailed answer in markdown format with code references, plus a link to view the full research session in the Sourcebot web UI.

Parameters:
| Name | Required | Description |
|:-------------|:---------|:-----------------------------------------------------------------|
| `fileName` | yes | The file to fetch the source code for. |
| `repoId` | yes | The Sourcebot repository ID. |
| Name | Required | Description |
|:----------------|:---------|:-----------------------------------------------------------------------------------------------------------------------------------------------|
| `query` | yes | The query to ask about the codebase. |
| `repos` | no | The repositories that are accessible to the agent during the chat. If not provided, all repositories are accessible. |
| `languageModel` | no | The language model to use for answering the question. Object with `provider` and `model`. If not provided, defaults to the first model in the config. Use `list_language_models` to see available options. |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Capitalize “Markdown” (proper noun).

Minor wording polish for the ask_codebase description.

✏️ Proposed fix
-Ask a natural language question about the codebase. This tool uses an AI agent to autonomously search code, read files, and find symbol references/definitions to answer your question. Returns a detailed answer in markdown format with code references, plus a link to view the full research session in the Sourcebot web UI.
+Ask a natural language question about the codebase. This tool uses an AI agent to autonomously search code, read files, and find symbol references/definitions to answer your question. Returns a detailed answer in Markdown format with code references, plus a link to view the full research session in the Sourcebot web UI.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Ask a natural language question about the codebase. This tool uses an AI agent to autonomously search code, read files, and find symbol references/definitions to answer your question. Returns a detailed answer in markdown format with code references, plus a link to view the full research session in the Sourcebot web UI.
Parameters:
| Name | Required | Description |
|:-------------|:---------|:-----------------------------------------------------------------|
| `fileName` | yes | The file to fetch the source code for. |
| `repoId` | yes | The Sourcebot repository ID. |
| Name | Required | Description |
|:----------------|:---------|:-----------------------------------------------------------------------------------------------------------------------------------------------|
| `query` | yes | The query to ask about the codebase. |
| `repos` | no | The repositories that are accessible to the agent during the chat. If not provided, all repositories are accessible. |
| `languageModel` | no | The language model to use for answering the question. Object with `provider` and `model`. If not provided, defaults to the first model in the config. Use `list_language_models` to see available options. |
Ask a natural language question about the codebase. This tool uses an AI agent to autonomously search code, read files, and find symbol references/definitions to answer your question. Returns a detailed answer in Markdown format with code references, plus a link to view the full research session in the Sourcebot web UI.
Parameters:
| Name | Required | Description |
|:----------------|:---------|:-----------------------------------------------------------------------------------------------------------------------------------------------|
| `query` | yes | The query to ask about the codebase. |
| `repos` | no | The repositories that are accessible to the agent during the chat. If not provided, all repositories are accessible. |
| `languageModel` | no | The language model to use for answering the question. Object with `provider` and `model`. If not provided, defaults to the first model in the config. Use `list_language_models` to see available options. |
🧰 Tools
🪛 LanguageTool

[uncategorized] ~220-~220: Did you mean the formatting language “Markdown” (= proper noun)?
Context: ... question. Returns a detailed answer in markdown format with code references, plus a lin...

(MARKDOWN_NNP)

🤖 Prompt for AI Agents
In `@docs/docs/features/mcp-server.mdx` around lines 220 - 227, Update the
ask_codebase tool description to capitalize the proper noun "Markdown" and apply
the minor wording polish: change the phrase "Returns a detailed answer in
markdown format with code references, plus a link to view the full research
session in the Sourcebot web UI." to use "Markdown" and improve clarity (e.g.,
"Returns a detailed answer in Markdown format with code references and a link to
view the full research session in the Sourcebot web UI."). Ensure the change is
made in the string for the ask_codebase description and the related
parameter/table text that currently contains "markdown" so the tool name
"ask_codebase" and the table entry for the return description reflect the
corrected capitalization and wording.

Comment on lines +248 to +260
### ask_codebase

Ask a natural language question about the codebase. This tool uses an AI agent to autonomously search code, read files, and find symbol references/definitions to answer your question. Returns a detailed answer in markdown format with code references, plus a link to view the full research session in the Sourcebot web UI.

<details>
<summary>Parameters</summary>

| Name | Required | Description |
|:----------------|:---------|:-----------------------------------------------------------------------------------------------------------------------------------------------|
| `query` | yes | The query to ask about the codebase. |
| `repos` | no | The repositories that are accessible to the agent during the chat. If not provided, all repositories are accessible. |
| `languageModel` | no | The language model to use for answering the question. Object with `provider` and `model`. If not provided, defaults to the first model in the config. Use `list_language_models` to see available options. |

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Fix minor doc/formatting nits (Markdown + table alignment).
These are minor, but will clear the lint hints (MARKDOWN_NNP, MD060).

✏️ Suggested doc fix
-Ask a natural language question about the codebase. This tool uses an AI agent to autonomously search code, read files, and find symbol references/definitions to answer your question. Returns a detailed answer in markdown format with code references, plus a link to view the full research session in the Sourcebot web UI.
+Ask a natural language question about the codebase. This tool uses an AI agent to autonomously search code, read files, and find symbol references/definitions to answer your question. Returns a detailed answer in Markdown format with code references, plus a link to view the full research session in the Sourcebot web UI.
@@
-| Name            | Required | Description                                                                                                                                    |
-|:----------------|:---------|:-----------------------------------------------------------------------------------------------------------------------------------------------|
-| `query`         | yes      | The query to ask about the codebase.                                                                                                           |
-| `repos`         | no       | The repositories that are accessible to the agent during the chat. If not provided, all repositories are accessible.                           |
-| `languageModel` | no       | The language model to use for answering the question. Object with `provider` and `model`. If not provided, defaults to the first model in the config. Use `list_language_models` to see available options. |
+| Name            | Required | Description                                                                                                                                                                                     |
+| :-------------- | :------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| `query`         | yes      | The query to ask about the codebase.                                                                                                                                                            |
+| `repos`         | no       | The repositories that are accessible to the agent during the chat. If not provided, all repositories are accessible.                                                                           |
+| `languageModel` | no       | The language model to use for answering the question. Object with `provider` and `model`. If not provided, defaults to the first model in the config. Use `list_language_models` to see options. |
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
### ask_codebase
Ask a natural language question about the codebase. This tool uses an AI agent to autonomously search code, read files, and find symbol references/definitions to answer your question. Returns a detailed answer in markdown format with code references, plus a link to view the full research session in the Sourcebot web UI.
<details>
<summary>Parameters</summary>
| Name | Required | Description |
|:----------------|:---------|:-----------------------------------------------------------------------------------------------------------------------------------------------|
| `query` | yes | The query to ask about the codebase. |
| `repos` | no | The repositories that are accessible to the agent during the chat. If not provided, all repositories are accessible. |
| `languageModel` | no | The language model to use for answering the question. Object with `provider` and `model`. If not provided, defaults to the first model in the config. Use `list_language_models` to see available options. |
### ask_codebase
Ask a natural language question about the codebase. This tool uses an AI agent to autonomously search code, read files, and find symbol references/definitions to answer your question. Returns a detailed answer in Markdown format with code references, plus a link to view the full research session in the Sourcebot web UI.
<details>
<summary>Parameters</summary>
| Name | Required | Description |
| :-------------- | :------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `query` | yes | The query to ask about the codebase. |
| `repos` | no | The repositories that are accessible to the agent during the chat. If not provided, all repositories are accessible. |
| `languageModel` | no | The language model to use for answering the question. Object with `provider` and `model`. If not provided, defaults to the first model in the config. Use `list_language_models` to see options. |
🧰 Tools
🪛 LanguageTool

[uncategorized] ~250-~250: Did you mean the formatting language “Markdown” (= proper noun)?
Context: ... question. Returns a detailed answer in markdown format with code references, plus a lin...

(MARKDOWN_NNP)

🪛 markdownlint-cli2 (0.20.0)

[warning] 259-259: Table column style
Table pipe does not align with header for style "aligned"

(MD060, table-column-style)

🤖 Prompt for AI Agents
In `@packages/mcp/README.md` around lines 248 - 260, The ask_codebase section's
Markdown table has alignment/formatting issues causing MARKDOWN_NNP/MD060 lint
warnings; fix by normalizing the table header and separator row (ensure the
header row uses pipes and the separator row uses matching colons/dashes like
"|:---|:---:|---:|" for intended alignment), make sure each cell is separated by
pipes with consistent whitespace, remove any stray blank lines or mismatched
backticks around column names (e.g., `query`, `repos`, `languageModel`) and
ensure the surrounding details/summary blocks are properly nested so the table
renders as a single contiguous block under the "Parameters" summary in the
ask_codebase section.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants