diff --git a/cmd/src/mcp_tools.json b/cmd/src/mcp_tools.json
new file mode 100644
index 0000000000..e38eba472d
--- /dev/null
+++ b/cmd/src/mcp_tools.json
@@ -0,0 +1,1008 @@
+{
+ "tools": [
+ {
+ "description": "This is a Sourcegraph search tool and is best used with other sourcegraph search tools. A commit search tool.\nSearch for commits in the repository. Find who made changes, when features were implemented, or track code history.\n\nKey features:\n- Search commit messages for relevant terms\n- Find commits by specific authors\n- Search for changes containing specific code\n- Filter by file paths or repository\n- Filter by date ranges with before/after\n- Regex pattern support\n\nLogic: All parameter types are combined with AND, but within each parameter type, multiple values use OR.\nExample: messageTerms=[\"bug\",\"fix\"] + authors=[\"jane\"] finds commits by jane with \"bug\" OR \"fix\" in message.\n\nExamples:\n\n \n Search for commits mentioning 'implement feature' or 'create feature' in the message\n calls the commit search tool with messageTerms=[\"implement feature\", \"create feature\"] repos=[\"github.com/myorg/repo\"]\n \n\t\n Search for commits that added pandas imports\n calls the commit search tool with contentTerms=[\"import pandas\"] repos=[\"github.com/myorg/repo\"]\n \n \n Find commits by jane.doe that changed files in the ui/components directory\n calls the commit search tool with authors=[\"jane.doe\"] files=[\"ui/components/**\"] repos=[\"github.com/myorg/frontend\"]\n \n \n Find changes to authentication code in May 2025\n calls the commit search tool with contentTerms=[\"auth\"] repos=[\"github.com/myorg/auth-service\", \"github.com/myorg/user-service\"] after=\"2025-05-01\" before=\"2025-05-31\"\n \n \n What has John been working on for the past month?\n calls the commit search tool with authors=[\"John\"] repos=[\"github.com/myorg/repo1\", \"github.com/myorg/repo2\"] after=\"1 month ago\"\n \n",
+ "inputSchema": {
+ "type": "object",
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "required": [
+ "repos"
+ ],
+ "properties": {
+ "after": {
+ "type": "string",
+ "description": "Search for commits after this date. Supports various formats including structured dates (e.g. \"YYYY-MM-DD\" or \"MM/DD/YYYY\", or \"november 2023\") and natural language (e.g. \"1 month ago\", \"last week\", or \"yesterday\")"
+ },
+ "authors": {
+ "type": "array",
+ "description": "Authors to filter by. Multiple authors will be combined with OR logic.",
+ "items": {
+ "type": "string"
+ }
+ },
+ "before": {
+ "type": "string",
+ "description": "Search for commits before this date. Supports various formats including structured dates (e.g. \"YYYY-MM-DD\", \"MM/DD/YYYY\", or \"november 2023\") and natural language (e.g. \"1 month ago\", \"last week\", or \"yesterday\")"
+ },
+ "contentTerms": {
+ "type": "array",
+ "description": "Code content terms to search for in the actual changes. Multiple terms will be combined with OR logic.",
+ "items": {
+ "type": "string"
+ }
+ },
+ "count": {
+ "type": "integer",
+ "description": "Maximum number of results to return"
+ },
+ "files": {
+ "type": "array",
+ "description": "File paths to filter by. Multiple files will be combined with OR logic.",
+ "items": {
+ "type": "string"
+ }
+ },
+ "messageTerms": {
+ "type": "array",
+ "description": "Terms to search for in commit messages. Multiple terms will be combined with OR logic by default.",
+ "items": {
+ "type": "string"
+ }
+ },
+ "repos": {
+ "type": "array",
+ "description": "REQUIRED: Repositories to search in (e.g., [\"github.com/gohugoio/hugo\"] or [\"repo1\", \"repo2\"]). Multiple repositories will be combined with OR logic.",
+ "items": {
+ "type": "string"
+ }
+ },
+ "useRegex": {
+ "type": "boolean",
+ "description": "Use regular expressions for searching (default: false)"
+ }
+ },
+ "additionalProperties": false
+ },
+ "name": "sg_commit_search",
+ "outputSchema": {
+ "type": "object",
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "required": [
+ "query",
+ "totalCount",
+ "commits",
+ "limitHit"
+ ],
+ "properties": {
+ "commits": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "required": [
+ "repository",
+ "commit",
+ "author",
+ "date",
+ "title",
+ "message"
+ ],
+ "properties": {
+ "author": {
+ "type": "string"
+ },
+ "commit": {
+ "type": "string"
+ },
+ "date": {
+ "type": "string"
+ },
+ "message": {
+ "type": "string"
+ },
+ "repository": {
+ "type": "string"
+ },
+ "title": {
+ "type": "string"
+ }
+ },
+ "additionalProperties": false
+ }
+ },
+ "limitHit": {
+ "type": "boolean"
+ },
+ "query": {
+ "type": "string"
+ },
+ "totalCount": {
+ "type": "integer"
+ }
+ },
+ "additionalProperties": false
+ }
+ },
+ {
+ "description": "This is a Sourcegraph search tool and is best used with other sourcegraph search tools. A tool that compares changes between two specific revisions in a repository.\nUse this tool when you need to:\n- Compare changes between two versions (commits, branches, tags) in a single repository\n- View specific file changes between revisions in detail\n- Examine code differences in a pull request, branch or commit\n- See all files modified between two specific points in a repository\n\nTips for effective revision comparison:\n- Use specific revisions for precise comparisons\n- For very large diffs, start with a smaller \"first\" value (e.g., 5) to preview changes\n- For comparing across branches, use the branch names directly\n- To see changes from a specific commit, use commitHash~1 as base and commitHash as head\n- Use \"after\" with the provided endCursor value to paginate through large diffs\n\nExamples:\n\n \n What changed in commit abc123 in the github.com/django/django repository?\n calls the compare revisions tool with repo=\"github.com/django/django\" base=\"abc123~1\" head=\"abc123\"\n \n \n Compare the feature-auth branch with main in the github.com/microsoft/vscode repository\n calls the compare revisions tool with repo=\"github.com/microsoft/vscode\" base=\"main\" head=\"feature-auth\"\n \n \n Show me all file changes between commits abc123 and def456 in kubernetes\n calls the compare revisions tool with repo=\"github.com/kubernetes/kubernetes\" base=\"abc123\" head=\"def456\"\n \n \n What files were modified in the last 3 commits on main branch of the rails repo?\n calls the compare revisions tool with repo=\"github.com/rails/rails\" base=\"main~3\" head=\"main\"\n \n",
+ "inputSchema": {
+ "type": "object",
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "required": [
+ "repo",
+ "base",
+ "head"
+ ],
+ "properties": {
+ "after": {
+ "type": "string",
+ "description": "Pagination cursor for fetching more results"
+ },
+ "base": {
+ "type": "string",
+ "description": "The base revision (older version, e.g., \"main~5\", a commit hash, or a tag)"
+ },
+ "first": {
+ "type": "integer",
+ "description": "Maximum number of file diffs to return (default: 50, max: 100)"
+ },
+ "head": {
+ "type": "string",
+ "description": "The head revision (newer version, e.g., \"main\", a commit hash, or a tag)"
+ },
+ "repo": {
+ "type": "string",
+ "description": "The repository name to compare revisions in (e.g., \"github.com/grafana/loki\")"
+ }
+ },
+ "additionalProperties": false
+ },
+ "name": "sg_compare_revisions",
+ "outputSchema": {
+ "type": "object",
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "required": [
+ "repository",
+ "base",
+ "head",
+ "totalAdded",
+ "totalDeleted",
+ "totalModified",
+ "files",
+ "hasNextPage",
+ "endCursor"
+ ],
+ "properties": {
+ "base": {
+ "type": "string"
+ },
+ "endCursor": {
+ "type": "string"
+ },
+ "files": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "required": [
+ "path",
+ "added",
+ "deleted"
+ ],
+ "properties": {
+ "added": {
+ "type": "integer"
+ },
+ "deleted": {
+ "type": "integer"
+ },
+ "hunks": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "required": [
+ "oldRange",
+ "newRange",
+ "body"
+ ],
+ "properties": {
+ "body": {
+ "type": "string"
+ },
+ "newRange": {
+ "type": "object",
+ "required": [
+ "startLine",
+ "lines"
+ ],
+ "properties": {
+ "lines": {
+ "type": "integer"
+ },
+ "startLine": {
+ "type": "integer"
+ }
+ },
+ "additionalProperties": false
+ },
+ "oldRange": {
+ "type": "object",
+ "required": [
+ "startLine",
+ "lines"
+ ],
+ "properties": {
+ "lines": {
+ "type": "integer"
+ },
+ "startLine": {
+ "type": "integer"
+ }
+ },
+ "additionalProperties": false
+ },
+ "section": {
+ "type": "string"
+ }
+ },
+ "additionalProperties": false
+ }
+ },
+ "path": {
+ "type": "string"
+ }
+ },
+ "additionalProperties": false
+ }
+ },
+ "hasNextPage": {
+ "type": "boolean"
+ },
+ "head": {
+ "type": "string"
+ },
+ "repository": {
+ "type": "string"
+ },
+ "totalAdded": {
+ "type": "integer"
+ },
+ "totalDeleted": {
+ "type": "integer"
+ },
+ "totalModified": {
+ "type": "integer"
+ }
+ },
+ "additionalProperties": false
+ }
+ },
+ {
+ "description": "\nCreate a new deep search conversation to answer complex questions about your codebase.\n\nPowered by an agentic LLM, this deep research tool performs an in-depth investigation of your codebase\n- Performs comprehensive analysis of your question\n- Uses multiple search and analysis tools automatically\n- Provides detailed, well-researched answers with evidence\n- Generates related follow-up suggestions\n\nUse this tool when you need:\n- Comprehensive analysis of complex technical questions\n- Multi-step research across one or many remote codebases\n- Detailed explanations with supporting evidence\n- Questions that require combining information from multiple sources\n\nExamples:\n\n\n\tHow does authentication work in this codebase?\n\tcalls the deep search tool with question: \"How does authentication work in this codebase?\"\n\n\n\tFind all the security vulnerabilities related to user input validation\n\tcalls the deep search tool with question: \"Find all the security vulnerabilities related to user input validation\"\n\n\n\tExplain the architecture and data flow of the payment processing system\n\tcalls the deep search tool with question: \"Explain the architecture and data flow of the payment processing system\"\n\n",
+ "inputSchema": {
+ "type": "object",
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "required": [
+ "question"
+ ],
+ "properties": {
+ "question": {
+ "type": "string",
+ "description": "The question to research using deep search. Should be detailed and specific about what you want to understand."
+ }
+ },
+ "additionalProperties": false
+ },
+ "name": "sg_deepsearch",
+ "outputSchema": {
+ "type": "object",
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "required": [
+ "conversation_id",
+ "question_id"
+ ],
+ "properties": {
+ "answer": {
+ "type": "string",
+ "description": "The answer generated by the deep search tool."
+ },
+ "conversation_id": {
+ "type": "integer",
+ "description": "The ID of the conversation that was created to process the question. Can be used for follow-up questions"
+ },
+ "error": {
+ "type": "object",
+ "description": "Any error that occurred during the deep search process.",
+ "required": [
+ "title",
+ "kind",
+ "message"
+ ],
+ "properties": {
+ "details": {
+ "type": "string"
+ },
+ "kind": {
+ "type": "string"
+ },
+ "message": {
+ "type": "string"
+ },
+ "title": {
+ "type": "string"
+ }
+ },
+ "additionalProperties": false
+ },
+ "link": {
+ "type": "string",
+ "description": "A link to the deep search conversation app."
+ },
+ "question_id": {
+ "type": "integer",
+ "description": "The globally unique ID of the question that was processed."
+ },
+ "suggested_followups": {
+ "type": "array",
+ "description": "Suggested follow-up questions based on the deep search result.",
+ "items": {
+ "type": "string"
+ }
+ },
+ "title": {
+ "type": "string",
+ "description": "The title or summary of the deep search result."
+ }
+ },
+ "additionalProperties": false
+ }
+ },
+ {
+ "description": "This is a Sourcegraph search tool and is best used with other sourcegraph search tools. A tool that searches for code changes (diffs) across multiple repositories.\nThis tool searches ONLY the actual code changes (added/removed lines), not commit messages.\n\nUse this tool when you need to:\n- Find specific code patterns that were added or removed across repositories\n- Search for keywords in code changes across multiple repositories\n- Find changes related to specific features or bugs\n\nTips for effective diff searches:\n- Use the 'repos' parameter to focus your search on specific repositories\n- Use 'after' and 'before' to define a time range for the changes\n- Use 'pattern' to specify what you're looking for in the changed code\n- Add 'useRegex: true' for more complex search patterns\n- Use 'added: true' or 'removed: true' to search only in added or removed code\n\nExamples:\n\n \n Find instances where console.log was added across our repos in the past month\n calls the diff search tool with pattern=\"console.log\" after=\"1 month ago\" added=true\n \n \n Search for any hardcoded passwords that were removed in our backend services\n calls the diff search tool with pattern=\"password.*=\" repos=[\"github.com/myorg/backend*\"] removed=true useRegex=true\n \n \n Look for recent changes that mention 'API key' across all our microservices\n calls the diff search tool with pattern=\"API key\" repos=[\"github.com/myorg/service-*\"] after=\"2 weeks ago\"\n \n \n Find security-related code changes by author john.doe in the last quarter\n calls the diff search tool with pattern=\"security|auth|login\" author=\"john.doe\" after=\"3 months ago\" useRegex=true\n \n \n Search for any database connection changes across all repositories recently\n calls the diff search tool with pattern=\"database|db_connect|connection\" after=\"1 week ago\" useRegex=true\n \n",
+ "inputSchema": {
+ "type": "object",
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "required": [
+ "pattern",
+ "repos"
+ ],
+ "properties": {
+ "added": {
+ "type": "boolean",
+ "description": "If true, only search in added code (default: search in both added and removed code)"
+ },
+ "after": {
+ "type": "string",
+ "description": "Only include results from changes after this time (e.g., \"2 weeks ago\", \"2023-01-01\")"
+ },
+ "author": {
+ "type": "string",
+ "description": "Filter by the author of the changes (e.g., \"username\")"
+ },
+ "before": {
+ "type": "string",
+ "description": "Only include results from changes before this time (e.g., \"1 week ago\", \"2023-12-31\")"
+ },
+ "count": {
+ "type": "integer",
+ "description": "Maximum number of results to return"
+ },
+ "pattern": {
+ "type": "string",
+ "description": "The search pattern to look for in diff content (code changes, actual added/removed lines)"
+ },
+ "removed": {
+ "type": "boolean",
+ "description": "If true, only search in removed code (default: search in both added and removed code)"
+ },
+ "repos": {
+ "type": "array",
+ "description": "REQUIRED: Array of repository patterns to search in (e.g., [\"github.com/myorg/repo\", \"github.com/otherorg/*\"]). Multiple repositories will be combined with OR logic.",
+ "items": {
+ "type": "string"
+ }
+ },
+ "useRegex": {
+ "type": "boolean",
+ "description": "Use regular expressions for searching (default: false)"
+ }
+ },
+ "additionalProperties": false
+ },
+ "name": "sg_diff_search",
+ "outputSchema": {
+ "type": "object",
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "required": [
+ "query",
+ "results",
+ "totalCount",
+ "limitHit"
+ ],
+ "properties": {
+ "limitHit": {
+ "type": "boolean"
+ },
+ "query": {
+ "type": "string"
+ },
+ "results": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "required": [
+ "repository",
+ "commit",
+ "diffHunk",
+ "url",
+ "matchRanges"
+ ],
+ "properties": {
+ "authorName": {
+ "type": "string"
+ },
+ "commit": {
+ "type": "string"
+ },
+ "diffHunk": {
+ "type": "string"
+ },
+ "matchRanges": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "required": [
+ "startLine",
+ "endLine",
+ "startCharacter",
+ "endCharacter"
+ ],
+ "properties": {
+ "endCharacter": {
+ "type": "integer"
+ },
+ "endLine": {
+ "type": "integer"
+ },
+ "startCharacter": {
+ "type": "integer"
+ },
+ "startLine": {
+ "type": "integer"
+ }
+ },
+ "additionalProperties": false
+ }
+ },
+ "message": {
+ "type": "string"
+ },
+ "repository": {
+ "type": "string"
+ },
+ "url": {
+ "type": "string"
+ }
+ },
+ "additionalProperties": false
+ }
+ },
+ "totalCount": {
+ "type": "integer"
+ }
+ },
+ "additionalProperties": false
+ }
+ },
+ {
+ "description": "This is a Sourcegraph search tool and is best used with other sourcegraph search tools. Finds references to a provided symbol in a repository.\nA symbol is any code identifier, such as a function name, variable name, or class name.\nIt handles overloading by leveraging compiler information to ensure references are to the exact symbol requested. It can even handle cross-repository references.\n\nReturns a list of usages of that symbol, specifically:\n- Where the symbol is referenced in the code\n- The file and line number of each reference\n- Surrounding context of each reference to help understand its usage\nIf the symbol is not found, returns \"Symbol not found\"\n\nThis tool is the opposite of the sg_go_to_definition tool - it finds references (usages) to a symbol given its definition.\n\nYou should use this tool when you have a specific symbol in mind (function, method, variable, class, etc.), you know where it is defined (a file path) and want to see where it is referenced / used in the codebase.\n\nYou should choose to use this tool over sg_keyword_search, sg_nls_search or sg_read_file when you have encountered the definition of a specific symbol (function, variable, class)\nand you want to see how that specific symbol is used throughout the codebase, understand code flow or performing impact analysis.\n\nExamples:\n\n\t\n\t\tFind where the AbstractPaymentProcessorClass is used. It's defined in src/processors/AbstractPaymentProcessor.ts in the ecommerce/payment-service repository.\n\t\t [calls the find references tool with repo=\"ecommerce/payment-service\", path=\"src/processors/AbstractPaymentProcessor.ts\", symbol=\"AbstractPaymentProcessor\"]\n\t\t {\n \"repo\": \"ecommerce/payment-service\",\n \"path\": \"src/processors/StripePaymentProcessor.ts\",\n \"rev\": \"HEAD\",\n \"chunks\": [\n\t\t\t\t\t{\n\t\t\t\t\t\t\"startLine\": 2,\n\t\t\t\t\t\t\"endLine\": 2,\n\t\t\t\t\t\t\"content\": \"2: import { AbstractPaymentProcessor } from './AbstractPaymentProcessor';\\n\"\n\t\t\t\t\t},\n {\n \"startLine\": 102,\n \"endLine\": 103,\n \"content\": \"102: class StripePaymentProcessor extends AbstractPaymentProcessor {\\n103: \\tprivate readonly Status status;\\n\"\n }\n ]\n }\n\t\t\n\t\n",
+ "inputSchema": {
+ "type": "object",
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "required": [
+ "repo",
+ "path",
+ "symbol"
+ ],
+ "properties": {
+ "path": {
+ "type": "string",
+ "description": "The path to the file within the repository containing the symbol reference, e.g. \"src/utils/date.ts\"."
+ },
+ "repo": {
+ "type": "string",
+ "description": "The name of the repository containing the file, e.g. \"github.com/tuckersoft/thronglets\"."
+ },
+ "revision": {
+ "type": "string",
+ "description": "The revision or branch to find references in. If not specified, defaults to the HEAD of the default branch."
+ },
+ "symbol": {
+ "type": "string",
+ "description": "The name of the symbol (function name, method name, class, variable, constant, etc) to find references for, e.g. \"handleSearch\"."
+ }
+ },
+ "additionalProperties": false
+ },
+ "name": "sg_find_references",
+ "outputSchema": {
+ "type": "object",
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "required": [
+ "fileBlocks"
+ ],
+ "properties": {
+ "fileBlocks": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "required": [
+ "type",
+ "repo",
+ "file",
+ "chunks"
+ ],
+ "properties": {
+ "chunks": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "required": [
+ "startLine",
+ "endLine",
+ "content"
+ ],
+ "properties": {
+ "content": {
+ "type": "string"
+ },
+ "endLine": {
+ "type": "integer"
+ },
+ "startLine": {
+ "type": "integer"
+ }
+ },
+ "additionalProperties": false
+ }
+ },
+ "file": {
+ "type": "string"
+ },
+ "repo": {
+ "type": "string"
+ },
+ "rev": {
+ "type": "string"
+ },
+ "type": {
+ "type": "string"
+ }
+ },
+ "additionalProperties": false
+ }
+ }
+ },
+ "additionalProperties": false
+ }
+ },
+ {
+ "description": "This is a Sourcegraph search tool and is best used with other sourcegraph search tools. Find repositories where a specific contributor has made commits.\nThis tool helps identify which repositories a person has contributed to, making it useful for scoping commit searches.\n\nUse this tool when you need to:\n- Find all repositories a person has worked on\n- Scope commit or diff searches to relevant repositories\n- Understand a contributor's involvement across the codebase\n\nThe tool searches by author name or email address and returns repositories with contribution statistics.\n\nExamples:\n\n\t\n\t\tWhat repositories has Jim contributed to?\n\t\tcalls get contributor repos tool with author=\"Jim\"\n\t\n\t\n\t\tWhat has john.doe@company.com been working on?\n\t\tcalls get contributor repos tool with author=\"john.doe@company.com\"\n\t\n",
+ "inputSchema": {
+ "type": "object",
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "required": [
+ "author"
+ ],
+ "properties": {
+ "author": {
+ "type": "string",
+ "description": "Author name or email address to search for. Case-insensitive partial matching (e.g., \"john\" will match \"john.doe@company.com\" and \"John Smith\")."
+ },
+ "limit": {
+ "type": "integer",
+ "description": "Maximum number of repositories to return. Defaults to 20, max 100."
+ },
+ "minCommits": {
+ "type": "integer",
+ "description": "Minimum number of commits the author must have in a repository to include it. Defaults to 1."
+ }
+ },
+ "additionalProperties": false
+ },
+ "name": "sg_get_contributor_repos",
+ "outputSchema": {
+ "type": "object",
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "required": [
+ "repositories"
+ ],
+ "properties": {
+ "repositories": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "required": [
+ "repoName",
+ "repoCommitCount",
+ "repoMostRecentCommitDate"
+ ],
+ "properties": {
+ "repoCommitCount": {
+ "type": "integer"
+ },
+ "repoMostRecentCommitDate": {
+ "type": "string"
+ },
+ "repoName": {
+ "type": "string"
+ }
+ },
+ "additionalProperties": false
+ }
+ }
+ },
+ "additionalProperties": false
+ }
+ },
+ {
+ "description": "This is a Sourcegraph search tool and is best used with other sourcegraph search tools. Finds the definition of a specified symbol in a repository.\nThis tool can leverage compiler-level symbol information to provide accurate results and can handle cross-repository references.\n\nA symbol is any code identifier, such as a function or method name, variable name, or class name such as 'MyClass' or 'readFile'.\nThe symbol name should be the identifier as it appears in code (e.g., 'validateToken', 'MyClass', 'API_ENDPOINT').\nFor methods, use just the method name without the class prefix.\nFor nested symbols, use the simple name rather than fully qualified paths.\n\nThe tool will return the code snippet containing the definition of the symbol in the codebase, as well as its location - the file name and line number.\nIt will return up to 50 lines of the code snippet containing the definition of the symbol.\n\nThis tool is the opposite of the sg_find_references tool - it finds the definition to a symbol given a reference/usage symbol.\n\nYou should use this tool when you have a specific symbol in mind (function, method, variable, class, etc.), you know where it is used (a file path) and want to see its definition in the codebase.\n\nYou should choose to use this tool over sg_keyword_search, sg_nls_search or sg_read_file when you have encountered a specific symbol (function, method, variable, class, etc.)\nthat you want to understand better by seeing its definition.\n\nExamples:\n\n \n I'm working in the auth-service/backend repo, in the file src/middleware/authMiddleware.js. This code calls await validateToken(session, token). Where is the function validateToken defined?\n [calls the go to definition tool with repo=\"auth-service/backend\", path=\"src/middleware/authMiddleware.js\", symbol=\"validateToken\"]\n {\n \"repo\": \"auth-service/backend\",\n \"path\": \"src/middleware/validation.js\",\n \"rev\": \"HEAD\",\n \"chunks\": [\n {\n \"startLine\": 12,\n \"endLine\": 62,\n \"content\": \"12: function validateToken(session, token) { ... }\"\n }\n ]\n }\n \n \n",
+ "inputSchema": {
+ "type": "object",
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "required": [
+ "repo",
+ "path",
+ "symbol"
+ ],
+ "properties": {
+ "path": {
+ "type": "string",
+ "description": "The path to the file within the repository containing the symbol reference."
+ },
+ "repo": {
+ "type": "string",
+ "description": "The name of the repository containing the file. For example, \"github.com/burntsushi/ripgrep\"."
+ },
+ "revision": {
+ "type": "string",
+ "description": "The revision or branch to find the definition in. If not specified, defaults to the HEAD of the default branch."
+ },
+ "symbol": {
+ "type": "string",
+ "description": "The name of the symbol to find the definition for."
+ }
+ },
+ "additionalProperties": false
+ },
+ "name": "sg_go_to_definition",
+ "outputSchema": {
+ "type": "object",
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "required": [
+ "fileBlocks"
+ ],
+ "properties": {
+ "fileBlocks": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "required": [
+ "type",
+ "repo",
+ "file",
+ "chunks"
+ ],
+ "properties": {
+ "chunks": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "required": [
+ "startLine",
+ "endLine",
+ "content"
+ ],
+ "properties": {
+ "content": {
+ "type": "string"
+ },
+ "endLine": {
+ "type": "integer"
+ },
+ "startLine": {
+ "type": "integer"
+ }
+ },
+ "additionalProperties": false
+ }
+ },
+ "file": {
+ "type": "string"
+ },
+ "repo": {
+ "type": "string"
+ },
+ "rev": {
+ "type": "string"
+ },
+ "type": {
+ "type": "string"
+ }
+ },
+ "additionalProperties": false
+ }
+ }
+ },
+ "additionalProperties": false
+ }
+ },
+ {
+ "description": "This is a Sourcegraph search tool and is best used with other sourcegraph search tools. \nA keyword code search tool that helps you find relevant code snippets across repositories. Use this tool when you need to:\n- Find specific code with exact matching\n- Verify if certain code exists in the codebase\n- Find examples of code usage\n\nSearch capabilities:\n- Basic search: Enter keywords to find code containing those terms\n- Boolean search: Use AND/OR operators to combine terms. By default, all search terms are combined with AND, meaning that all search terms must match for a result to be included.\n- Filters:\n\t* repo: to search specific repositories (supports regex) Example: repo:github.com/google will select all repositories with the matching prefix (github.com/google-gemini/cookbook and github.com/google/neuroglancer both match). Use ^ to match the start of the string and $ to match the end of the string to avoid unwanted matches. You can chain multiple repo filters with OR while putting them in parentheses.\n\t* file: to search specific file patterns (supports regex) Example: file:README.md will only search files that have README.md in their name. file:.*.ts will search all files with a .ts extension.\n\t* rev: to search specific revisions (branches, tags, commits/sha). MUST always be used together with a repo: filter. Example: repo:^foo/bar$ rev:feat/xyz will only search the branch feat/xyz of the repo foo/bar. If not specified, defaults to the HEAD of the default branch.\n\nWhen not to use this tool:\n- For semantic or conceptual searches like 'authentication implementation'\n- For queries that are similar to natural language like \"API calls to middleware in admin panel\".\n- When you are not sure if the term exists in the codebase.\n- For queries with several search terms.\n- For exploratory searching of the codebase, when you are not sure what a certain term or name means.\nImportant: In these cases, use the sg_nls_search tool instead.\n\nBest practices:\n- Use a small (1-3) number of search terms. Because we combine terms with AND by default, using too many terms may result in no results.\n- Use specific, descriptive search terms\n- Start with broader searches and narrow down using filters\n- Use repo: and file: filters to improve result relevance\n- The results are case insensitive, so you should not repeat the same search term with different capitalization.\n- Use regex (file:.*.py) instead of glob (file:*.py) for searching files with a .py extension\n- Don't use the rev: filter unless the user specifically asks for a particular branch, tag, or commit. The default behavior is to search the HEAD of the default branch.\nImportant: Use the literal OR between search terms if you are looking for code containing at least one of the terms. Do not use regex or with |.\n\nReturns the top 3 most relevant code chunks (truncated to 1024 characters) from each matching file (up to 15 files).\nIndividual lines longer than 256 characters are truncated.\n\nExamples:\n\n\n\tFind all code in the secret-fellowship organization on Github using log4j\n\tcalls the keyword search tool with query: \"repo:^github.com/secret-fellowship log4j\"\n\n\n\tFind all code in the github.com/kubernetes/autoscaler repo that uses the http.NewRequest function\n\tcalls the keyword search tool with query: \"repo:^github.com/kubernetes/autoscaler$ http.NewRequest\"\n\n\n\tFind Go code in ollama where memory mapping is used on darwin or linux\n\tcalls the keyword search tool with query: \"repo:ollama file:.*.go mmap AND (darwin OR linux)\"\n\n\n\tFind FAQs in all readme files across all repositories\n\tcalls the keyword search tool with query: \"file:README.md FAQ\"\n\n\n\tFind code in bar or foo repos that uses lodash\n\tcalls the keyword search tool with query: \"(repo:foo OR repo:bar) lodash\"\n\n\n\tFind code containing either foo or bar in the dev/docs directory\n\tcalls the keyword search tool with query: \"file:^dev/docs foo OR bar\"\n\n\n\tFind code containing foo in dev/docs directory of the repo bar/bas on branch quz/user>\n\tcalls the keyword search tool with query: \"repo:^bar/bas$ rev:quz file:^dev/docs foo\"\n\n",
+ "inputSchema": {
+ "type": "object",
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "required": [
+ "query"
+ ],
+ "properties": {
+ "query": {
+ "type": "string",
+ "description": "The search query. Can include keywords, regex patterns, and filters."
+ }
+ },
+ "additionalProperties": false
+ },
+ "name": "sg_keyword_search",
+ "outputSchema": {
+ "type": "object",
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "required": [
+ "blocks"
+ ],
+ "properties": {
+ "blocks": {
+ "type": "array",
+ "items": true
+ }
+ },
+ "additionalProperties": false
+ }
+ },
+ {
+ "description": "This is a Sourcegraph search tool and is best used with other sourcegraph search tools. Lists the files and subdirectories in the workspace in a given directory.\nDirect subdirectories are included and the path is returned with a trailing slash.\nThe input path is relative to the root of the repository.\n\nLists up to 1000 files or directories. If there are more, the response will be truncated.\nDirectories are listed first.\n\nExamples:\n\n\t\n\t\tList all files in the src directory of the repository.\n\t\tCalls the list files tool with path: \"src\"\n\t\t[{\"path\": \"app/\", \"isDirectory\": true}, {\"path\": \"DEV.md\", \"isDirectory\": false}]\n\t\n\n",
+ "inputSchema": {
+ "type": "object",
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "required": [
+ "repo"
+ ],
+ "properties": {
+ "path": {
+ "type": "string",
+ "description": "The directory path within the workspace to list files from. Defaults to workspace root if not specified."
+ },
+ "repo": {
+ "type": "string",
+ "description": "The name of the repository containing the files. For example, \"github.com/torvalds/linux\"."
+ },
+ "revision": {
+ "type": "string",
+ "description": "The revision or branch to list files from. If not specified, defaults to the HEAD of the default branch."
+ }
+ },
+ "additionalProperties": false
+ },
+ "name": "sg_list_files",
+ "outputSchema": {
+ "type": "object",
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "required": [
+ "files"
+ ],
+ "properties": {
+ "files": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "required": [
+ "path",
+ "isDirectory"
+ ],
+ "properties": {
+ "isDirectory": {
+ "type": "boolean"
+ },
+ "path": {
+ "type": "string"
+ }
+ },
+ "additionalProperties": false
+ }
+ }
+ },
+ "additionalProperties": false
+ }
+ },
+ {
+ "description": "This is a Sourcegraph search tool and is best used with other sourcegraph search tools. \nLists repositories that match a search query.\nYou can use this tool to figure out the repositories the user wants to talk about.\nReturns repository names, descriptions, and other metadata.\nBy default, returns up to 50 repositories per page.\nSupports cursor-based pagination - the response will include cursor information that can be used to fetch the next or previous page of results.\nUse the \"after\" parameter with the \"endCursor\" from the previous response to get the next page, or \"before\" with \"startCursor\" to get the previous page.\n\nWhen to use this tool:\n- When you do not know the full name of a repository (e.g. the user asks to search the xyz repo, you can use this tool to get github.com/my-org/xyz)\n- When you have to find repositories by substring matching (e.g. you want to find all repositories that contain the word \"foobar\")\nThe pattern is not a regular expression, but uses substring matching on the name of the repo.\n\nExamples:\n\n\t\n\t\tFind repositories in the cool-kids-club org on Github\n\t\tCalls the list repos tool with query: \"github.com/cool-kids-club\"\n\t\n\t\n\t\tExplain the foo repository\n\t\tCalls the list repos tool with query: \"foo\"\n\t\n\t\n\t\tDo we have repositories named \"baz\" and \"qux\"?\n\t\tCalls the list repos tool with query \"baz\", calls the list repos tool with query \"qux\"\n\t\n",
+ "inputSchema": {
+ "type": "object",
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "required": [
+ "query"
+ ],
+ "properties": {
+ "after": {
+ "type": "string",
+ "description": "Cursor to start fetching results after. Use the \"endCursor\" from the previous response."
+ },
+ "before": {
+ "type": "string",
+ "description": "Cursor to start fetching results before. Use the \"startCursor\" from the previous response."
+ },
+ "limit": {
+ "type": "integer",
+ "description": "Maximum number of repositories to return per page. Defaults to 50."
+ },
+ "query": {
+ "type": "string",
+ "description": "A search query to filter repositories. For example, \"django\" to find repositories containing that term."
+ }
+ },
+ "additionalProperties": false
+ },
+ "name": "sg_list_repos",
+ "outputSchema": {
+ "type": "object",
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "required": [
+ "repositories",
+ "pagination"
+ ],
+ "properties": {
+ "pagination": {
+ "type": "object",
+ "required": [
+ "totalCount",
+ "hasNextPage",
+ "hasPreviousPage"
+ ],
+ "properties": {
+ "endCursor": {
+ "type": "string"
+ },
+ "hasNextPage": {
+ "type": "boolean"
+ },
+ "hasPreviousPage": {
+ "type": "boolean"
+ },
+ "startCursor": {
+ "type": "string"
+ },
+ "totalCount": {
+ "type": "integer"
+ }
+ },
+ "additionalProperties": false
+ },
+ "repositories": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "required": [
+ "name",
+ "description",
+ "private",
+ "archived",
+ "fork",
+ "stars"
+ ],
+ "properties": {
+ "archived": {
+ "type": "boolean"
+ },
+ "description": {
+ "type": "string"
+ },
+ "fork": {
+ "type": "boolean"
+ },
+ "name": {
+ "type": "string"
+ },
+ "private": {
+ "type": "boolean"
+ },
+ "stars": {
+ "type": "integer"
+ }
+ },
+ "additionalProperties": false
+ }
+ }
+ },
+ "additionalProperties": false
+ }
+ },
+ {
+ "description": "This is a Sourcegraph search tool and is best used with other sourcegraph search tools. \nA semantic code search tool that helps find relevant code snippets using flexible linguistic matching.\n\nUse this tool over sg_keyword_search when you need to:\n- Find code related to concepts rather than exact matches\n- Get broader results with more potential matches\n- Find code when you don't know the exact keyword to search for like symbol (function or variable) names\n- When the sg_keyword_search tool returns too few results\n\nSearch capabilities:\n- The core matching is also keyword-based, but it's more flexible and can match more terms\n- Uses stemming and OR binding between terms for broader matching (e.g. \"auth impl\" matches on either term)\n- Filters: same as sg_keyword_search tool\n\nWhen not to use this tool:\n- When you need exact string matches (use the sg_keyword_search tool instead)\n- When you're looking for specific function names or variables\n\nBest practices:\n- IMPORTANT: Extract relevant keywords from a natural language query and search with only the keywords - if a user asks \"How are database connections created or closed in the codebase?\", search with \"database connection create close\", not \"how are database connections created closed\"\n- For complex topics with multiple aspects, do separate searches for each main concept\n- Use repo: and file: filters to improve result relevance\n- If results seem off-target, try refining your query to be more specific or use filters to avoid unwanted results\n- The results are case insensitive, so you should not repeat the same search term with different capitalization\n\nReturns the top 3 most relevant code chunks (truncated to 1024 characters) from each matching file (up to 15 files).\nIndividual lines longer than 256 characters are truncated.\n\nExamples:\n\n\n\tFind where event listener handlers are set up in the codebase\n\tcalls the nls search tool with query: \"event listen handler\"\n\n\n\tExplain the code that controls the chat view in barfoo repo\n\tcalls the nls search tool with query: \"repo:barfoo$ view controller chat\"\n\n\n\tHow are database connections managed in the github.com/django/django repo?\n\tcalls the nls search tool with query: \"repo:^github.com/django/django$ database connection manage\"\n\n\n",
+ "inputSchema": {
+ "type": "object",
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "required": [
+ "query"
+ ],
+ "properties": {
+ "query": {
+ "type": "string",
+ "description": "The search query. Can include keywords, regex patterns, and filters."
+ }
+ },
+ "additionalProperties": false
+ },
+ "name": "sg_nls_search",
+ "outputSchema": {
+ "type": "object",
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "required": [
+ "blocks"
+ ],
+ "properties": {
+ "blocks": {
+ "type": "array",
+ "items": true
+ }
+ },
+ "additionalProperties": false
+ }
+ },
+ {
+ "description": "This is a Sourcegraph search tool and is best used with other sourcegraph search tools. \nReads the content of a file in the workspace.\nReturns the file content as a string.\nEach line is prefixed with its actual line number from the file. The line numbers are 1-indexed. If a file contains \"abc\\\\ndef\", you will receive \"1: abc\\\\n2: def\".\nYou can optionally specify a line range to read only a portion of the file.\nIf you attempt to read a file that is too large (limit is 128 KB), you will receive an error. In that case, retry with a smaller line range.\n\nIMPORTANT: Use this tool ONLY when you have already located the specific file.\nBefore using this tool:\n- ALWAYS verify both the repository and file exist by using sg_list_repos, sg_list_files, sg_keyword_search, or sg_nls_search first\n- NEVER try to read a file without first confirming it exists at the exact path\n- NEVER guess file paths or assume common structures like \"lib/shared/src\" exist - always verify\n\nExamples:\n\n\n\tSummarize the readme in the pytorch/torcheval repository\n\t[First checks that the repository exists by calling sg_list_repos]\n\t[Then verifies README.md exists using sg_list_files with repo: \"pytorch/torcheval\"]\n\tCalls the read file tool with repo: \"pytorch/torcheval\", path: \"README.md\"\n\n\n\tRead the first 100 lines of the code in cli/build.rs in the tokio-rs/tokio repository\n\t[First confirms the file exists using sg_list_files or sg_keyword_search]\n\tCalls the read file tool with repo: \"tokio-rs/tokio\", path: \"cli/build.rs\", startLine: 1, endLine: 100\n\n\n\tRead the first 100 lines of the code in cli/build.rs in the tokio-rs/tokio repository at commit 1234567890\n\t[First confirms the file exists using sg_list_files or sg_keyword_search]\n\tCalls the read file tool with repo: \"tokio-rs/tokio\", path: \"cli/build.rs\", startLine: 1, endLine: 100, revision: \"1234567890\"\n\n\n\tRead the first 100 lines of the code in cli/build.rs in the tokio-rs/tokio repository at branch feat/xzy\n\t[First confirms the file exists using sg_list_files or sg_keyword_search]\n\tCalls the read file tool with repo: \"tokio-rs/tokio\", path: \"cli/build.rs\", startLine: 1, endLine: 100, revision: \"feat/xzy\"\n\n",
+ "inputSchema": {
+ "type": "object",
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "required": [
+ "repo",
+ "path"
+ ],
+ "properties": {
+ "endLine": {
+ "type": "integer",
+ "description": "The 1-based line number to end reading at. If not specified, reads to the end of the file."
+ },
+ "path": {
+ "type": "string",
+ "description": "The path to the file within the repository."
+ },
+ "repo": {
+ "type": "string",
+ "description": "The name of the repository containing the file. For example, \"github.com/sveltejs/svelte\"."
+ },
+ "revision": {
+ "type": "string",
+ "description": "The revision to read the file from. If not specified, reads from the default branch. This can be a commit hash or a branch name"
+ },
+ "startLine": {
+ "type": "integer",
+ "description": "The 1-based line number to start reading from. If not specified, starts from the beginning of the file."
+ }
+ },
+ "additionalProperties": false
+ },
+ "name": "sg_read_file",
+ "outputSchema": {
+ "type": "object",
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "required": [
+ "content"
+ ],
+ "properties": {
+ "content": {
+ "type": "string"
+ }
+ },
+ "additionalProperties": false
+ }
+ }
+ ]
+}
diff --git a/scripts/gen-mcp-tool-json.sh b/scripts/gen-mcp-tool-json.sh
new file mode 100755
index 0000000000..82430a0e55
--- /dev/null
+++ b/scripts/gen-mcp-tool-json.sh
@@ -0,0 +1,21 @@
+#!/usr/bin/env bash
+
+DST=$1
+
+if [[ -z "${SRC_ACCESS_TOKEN}" ]]; then
+ echo "SRC_ACCESS_TOKEN is not set. Please set a access token for S2 (sourcegraph.sourcegraph.com)"
+ exit 1
+fi
+
+if [[ -z "$DST" ]]; then
+ echo "Usage: $0 "
+ exit 1
+fi
+
+curl \
+ -H "Content-Type: application/json" \
+ -H "Authorization: token ${SRC_ACCESS_TOKEN}" \
+ -X POST \
+ -d '{ "jsonrpc": "2.0", "id": 1, "method": "tools/list", "params": {}}' \
+ https://sourcegraph.sourcegraph.com/.api/mcp/v1 | grep 'data:' | cut -b 6- | jq '.result' > ${DST}
+