### lsmcp Development Quick Start (Bash) Source: https://github.com/mizchi/lsmcp/blob/main/README.md This bash script provides a quick start guide for developing the lsmcp project. It includes commands for installing dependencies, building the project, and running tests. It also shows how to run the project with memory monitoring enabled. ```bash # Quick start pnpm install pnpm build pnpm test # Run with memory monitoring node --expose-gc dist/lsmcp.js ``` -------------------------------- ### lsmcp Configuration File Example Source: https://github.com/mizchi/lsmcp/blob/main/CONTRIBUTING.md An example JSON configuration file (`.lsmcp/config.json`) for advanced setup. It demonstrates how to specify presets, settings like auto-indexing and concurrency, and Language Server Protocol (LSP) configurations. ```json { "$schema": "../node_modules/@mizchi/lsmcp/lsmcp.schema.json", "preset": "typescript", "settings": { "autoIndex": true, "indexConcurrency": 10 }, "lsp": { "bin": "custom-lsp-server", "args": ["--stdio"], "initializationOptions": { "customOption": true } } } ``` -------------------------------- ### Automated Haskell Setup Script Source: https://github.com/mizchi/lsmcp/blob/main/docs/HASKELL_SETUP.md Executes a shell script to automate the installation of ghcup, GHC, HLS, Cabal, and Stack. This is the recommended approach for a quick setup. ```bash ./scripts/setup-haskell.sh ``` -------------------------------- ### Install and Build Project Dependencies Source: https://github.com/mizchi/lsmcp/blob/main/CONTRIBUTING.md Installs project dependencies, builds the project, and runs tests using pnpm. This is a common setup step for Node.js projects. ```bash git clone https://github.com/mizchi/lsmcp.git cd lsmcp pnpm install pnpm build pnpm test ``` -------------------------------- ### Node.js Script to Test lsmcp Setup Source: https://github.com/mizchi/lsmcp/blob/main/docs/MCP_CLIENT_SETUP.md A Node.js script that spawns the lsmcp process and sends an initialize request with the correct string protocolVersion. It listens for stdout data to log the response. ```javascript const { spawn } = require('child_process'); const path = require('path'); const proc = spawn('lsmcp', ['-p', 'typescript'], { stdio: ['pipe', 'pipe', 'pipe'] }); const initRequest = JSON.stringify({ jsonrpc: '2.0', id: 1, method: 'initialize', params: { protocolVersion: '2024-11-05', // Must be a string capabilities: {}, clientInfo: { name: 'test-client', version: '1.0.0' } } }) + '\n'; proc.stdin.write(initRequest); proc.stdout.on('data', (data) => { console.log('Response:', data.toString()); }); ``` -------------------------------- ### Manual GHC and HLS Installation via ghcup Source: https://github.com/mizchi/lsmcp/blob/main/docs/HASKELL_SETUP.md Installs the recommended GHC version and the latest HLS version using ghcup commands. It also sets them as the default versions. ```bash ghcup install ghc recommended --set ghcup install hls latest --set ``` -------------------------------- ### Manual ghcup Installation Source: https://github.com/mizchi/lsmcp/blob/main/docs/HASKELL_SETUP.md Installs the ghcup version manager using a curl command. This is a prerequisite for manually installing GHC and HLS. ```bash curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh ``` -------------------------------- ### Install rust-analyzer Source: https://github.com/mizchi/lsmcp/blob/main/examples/rust-project/README.md Installs the rust-analyzer component for Rust development. This is a prerequisite for using LSP features with Rust projects. ```bash rustup component add rust-analyzer ``` -------------------------------- ### Install Go and gopls Source: https://github.com/mizchi/lsmcp/blob/main/CONTRIBUTING.md Installs the Go programming language and the gopls language server. This involves downloading Go from the official website and then using the go command to install gopls. ```bash # Install Go # See: https://go.dev/doc/install # Install gopls go install golang.org/x/tools/gopls@latest ``` -------------------------------- ### GitHub Actions Install GHC and HLS Source: https://github.com/mizchi/lsmcp/blob/main/docs/HASKELL_SETUP.md A GitHub Actions workflow snippet that installs the recommended GHC and latest HLS versions using ghcup. It ensures the ghcup environment is sourced before running the install commands. ```yaml - name: Install GHC and HLS run: | source "$HOME/.ghcup/env" ghcup install ghc recommended --set ghcup install hls latest --set ``` -------------------------------- ### JSON RPC Initialize Request with String Protocol Version Source: https://github.com/mizchi/lsmcp/blob/main/docs/MCP_CLIENT_SETUP.md Example of a correct JSON RPC initialize request where 'protocolVersion' is a string. This format is required for lsmcp MCP server configuration. ```json { "jsonrpc": "2.0", "id": 1, "method": "initialize", "params": { "protocolVersion": "2024-11-05", // ✅ String format "capabilities": {}, "clientInfo": { "name": "your-client", "version": "1.0.0" } } } ``` -------------------------------- ### Install .NET SDK and fsautocomplete Source: https://github.com/mizchi/lsmcp/blob/main/CONTRIBUTING.md Installs the .NET SDK and the fsautocomplete tool for F# development. This involves downloading the .NET SDK and then installing the tool globally using the dotnet CLI. ```bash # Install .NET SDK # See: https://dotnet.microsoft.com/download # Install fsautocomplete dotnet tool install -g fsautocomplete ``` -------------------------------- ### Manual Build Tools Installation via ghcup Source: https://github.com/mizchi/lsmcp/blob/main/docs/HASKELL_SETUP.md Optionally installs Cabal and Stack build tools using ghcup, setting them as the default versions. These are useful for managing Haskell projects. ```bash ghcup install cabal latest --set ghcup install stack latest --set ``` -------------------------------- ### GitHub Actions Setup Haskell with ghcup Source: https://github.com/mizchi/lsmcp/blob/main/docs/HASKELL_SETUP.md A GitHub Actions workflow snippet to set up Haskell using ghcup in a non-interactive and minimal mode. It downloads ghcup, runs the bootstrap script, and adds ghcup's bin directory to the PATH. ```yaml - name: Setup Haskell with ghcup run: | curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | \ BOOTSTRAP_HASKELL_NONINTERACTIVE=1 BOOTSTRAP_HASKELL_MINIMAL=1 sh echo "$HOME/.ghcup/bin" >> $GITHUB_PATH ``` -------------------------------- ### Verify HLS Installation Source: https://github.com/mizchi/lsmcp/blob/main/docs/HASKELL_SETUP.md Checks if the Haskell Language Server is installed and accessible by running its version command. This helps confirm the installation was successful. ```bash haskell-language-server-wrapper --version ``` -------------------------------- ### Install Python LSP Server (pip and uv) Source: https://github.com/mizchi/lsmcp/blob/main/CONTRIBUTING.md Provides multiple methods for installing Python language server support. It includes installation using pip, and a faster alternative using the 'uv' package manager. ```bash # Option 1: Pyright (recommended) npm install -g pyright # Option 2: python-lsp-server pip install python-lsp-server[all] # Option 3: Using uv (fast package manager) curl -LsSf https://astral.sh/uv/install.sh | sh uv tool install python-lsp-server[all] ``` -------------------------------- ### JSON RPC Initialize Request with Number Protocol Version (Incorrect) Source: https://github.com/mizchi/lsmcp/blob/main/docs/MCP_CLIENT_SETUP.md Example of an incorrect JSON RPC initialize request where 'protocolVersion' is a number. This format will be rejected by lsmcp. ```json { "jsonrpc": "2.0", "id": 1, "method": "initialize", "params": { "protocolVersion": 1, // ❌ Number format will be rejected "capabilities": {}, "clientInfo": { "name": "your-client", "version": "1.0.0" } } } ``` -------------------------------- ### Install Rust and rust-analyzer Source: https://github.com/mizchi/lsmcp/blob/main/CONTRIBUTING.md Installs the Rust toolchain and the rust-analyzer language server using rustup and a curl script. This is a prerequisite for Rust development. ```bash # Install Rust and rust-analyzer curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh rustup component add rust-analyzer ``` -------------------------------- ### lsmcp Configuration Example (JSON) Source: https://github.com/mizchi/lsmcp/blob/main/README.md This JSON snippet shows an example configuration for lsmcp, including schema, preset selection, and specific settings like auto indexing and concurrency. It demonstrates how to customize lsmcp's behavior for a project. ```json { "$schema": "../node_modules/@mizchi/lsmcp/lsmcp.schema.json", "preset": "tsgo", "settings": { "autoIndex": true, "indexConcurrency": 10 } } ``` -------------------------------- ### Run Haskell Language Tests Source: https://github.com/mizchi/lsmcp/blob/main/docs/HASKELL_SETUP.md Executes the Haskell language tests using pnpm, which likely verifies the HLS setup and its integration with the lsmcp project's testing framework. ```bash pnpm test tests/languages/language-tests/haskell.test.ts ``` -------------------------------- ### Install TypeScript Language Server (npm) Source: https://github.com/mizchi/lsmcp/blob/main/CONTRIBUTING.md Installs the TypeScript language server using npm. This is an option for setting up TypeScript/JavaScript language support. Includes both stable and experimental options. ```bash # Option 1: typescript-language-server (stable) npm install -g typescript typescript-language-server # Option 2: tsgo (faster, experimental) npm install -g @typescript/native-preview ``` -------------------------------- ### LSMCP Configuration for Rust Source: https://github.com/mizchi/lsmcp/blob/main/examples/rust-project/README.md Configures the .mcp.json file to define how lsmcp should interact with the Rust language server. It specifies the command and arguments to launch rust-analyzer. ```json { "mcpServers": { "rust": { "command": "node", "args": ["../../dist/lsmcp.js", "--bin", "rust-analyzer"] } } } ``` -------------------------------- ### Vitest Unit Test Example Source: https://github.com/mizchi/lsmcp/blob/main/CONTRIBUTING.md An example of a basic unit test written using Vitest, demonstrating the describe, it, and expect functions. This snippet shows how to structure a simple test case. ```typescript import { describe, it, expect } from "vitest"; describe("MyFeature", () => { it("should work correctly", () => { expect(myFunction()).toBe(expectedResult); }); }); ``` -------------------------------- ### Initialize LSMCP with tsgo preset via npm Source: https://context7.com/mizchi/lsmcp/llms.txt Command to install LSMCP and its dependencies and then initialize the project configuration using the `tsgo` preset, recommended for TypeScript projects. ```bash npm install -D @mizchi/lsmcp @typescript/native-preview npx @mizchi/lsmcp init -p tsgo claude mcp add lsmcp npx -- -y @mizchi/lsmcp -p tsgo ``` -------------------------------- ### Install Dependencies with pnpm Source: https://github.com/mizchi/lsmcp/blob/main/tests/README.md Installs all project dependencies using the pnpm install command. This command should be run to ensure that all necessary libraries and packages are available for the project to function correctly. ```bash pnpm install ``` -------------------------------- ### Example Document Filters for TypeScript and package.json (TypeScript) Source: https://github.com/mizchi/lsmcp/blob/main/docs/ja/lsp-spec.md Provides concrete examples of how to use the DocumentFilter interface. One filter targets TypeScript files by language and scheme, while another targets package.json files using a glob pattern. These examples illustrate practical application of the filter definition. ```typescript // TypeScript ファイル { language: 'typescript', scheme: 'file' } // package.json ファイル { language: 'json', pattern: '**/package.json' } ``` -------------------------------- ### Install MoonBit CLI Source: https://github.com/mizchi/lsmcp/blob/main/CONTRIBUTING.md Installs the MoonBit CLI tool using a curl script. This is required for MoonBit language development and integration. ```bash # Install MoonBit curl -fsSL https://cli.moonbitlang.com/install/unix.sh | bash export PATH="$HOME/.moon/bin:$PATH" ``` -------------------------------- ### HLS Project Configuration (Cabal) Source: https://github.com/mizchi/lsmcp/blob/main/docs/HASKELL_SETUP.md An `hie.yaml` configuration snippet for HLS projects managed with Cabal. This configures HLS to use Cabal for project setup. ```yaml cradle: cabal: ``` -------------------------------- ### HLS Project Configuration (Direct) Source: https://github.com/mizchi/lsmcp/blob/main/docs/HASKELL_SETUP.md A basic `hie.yaml` configuration for HLS, suitable for simple Haskell projects. It uses a direct cradle with no specific arguments. ```yaml cradle: direct: arguments: [] ``` -------------------------------- ### Example JavaScript Function Source: https://github.com/mizchi/lsmcp/blob/main/docs/lsp-spec.md A simple JavaScript function that takes two arguments, `a` and `b`, and returns their sum. This is used as an example within a notebook cell. ```javascript function add(a, b) { return a + b; } ``` -------------------------------- ### Install lsmcp with npm Source: https://github.com/mizchi/lsmcp/blob/main/README.md Installs the lsmcp package and TypeScript native preview for tsgo projects using npm. It also initializes lsmcp for tsgo and adds it to the Claude MCP agent. ```bash # tsgo (reccommended) npm add -D @mizchi/lsmcp @typescript/native-preview npx @mizchi/lsmcp init -p tsgo claude mcp add lsmcp npx -- -y @mizchi/lsmcp -p tsgo # with manual --bin claude mcp add lsmcp npx -- -y @mizchi/lsmcp --bin="" ``` -------------------------------- ### Add Rust to LSMCP Source: https://github.com/mizchi/lsmcp/blob/main/examples/rust-project/README.md Adds Rust support to the lsmcp system, specifying the rust-analyzer binary. This command integrates the Rust language tooling into the lsmcp environment. ```bash claude mcp add rust npx -- -y @mizchi/lsmcp -l rust --bin "rust-analyzer" ``` -------------------------------- ### Running Integration Tests with pnpm Source: https://github.com/mizchi/lsmcp/blob/main/tests/integration/README.md Commands to execute integration tests using pnpm. Includes options for running all tests, a specific test file, and enabling verbose output. Assumes pnpm is installed and configured for the project. ```bash # Run all integration tests pnpm test:integration # Run a specific test file pnpm test:integration tests/integration/lsp-diagnostics-stale-content.test.ts # Run tests with verbose output DEBUG=1 pnpm test:integration ``` -------------------------------- ### GET /get_project_overview Source: https://context7.com/mizchi/lsmcp/llms.txt Retrieves comprehensive project information, including structure, statistics, and diagnostics. ```APIDOC ## GET /get_project_overview ### Description Get comprehensive project information including structure, key components, statistics, and diagnostics in a single call. ### Method GET ### Endpoint /get_project_overview ### Parameters #### Query Parameters - **root** (string) - Required - The root directory of the project. ### Request Example ```javascript // Using MCP client to analyze a TypeScript project import { Client } from "@modelcontextprotocol/sdk/client/index.js"; import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js"; const transport = new StdioClientTransport({ command: "npx", args: ["-y", "@mizchi/lsmcp", "-p", "tsgo"], cwd: "/path/to/project" }); const client = new Client({ name: "analyzer", version: "1.0.0" }); await client.connect(transport); const result = await client.callTool({ name: "get_project_overview", arguments: { root: "/path/to/project" } }); // Output includes: project info, directory structure, symbol counts by kind, key components, diagnostics summary console.log(result.content[0].text); ``` ### Response #### Success Response (200) - **content** (array) - An array of text content representing the project overview. #### Response Example ```json { "content": [ { "text": "Project Overview\n==============\nProject: my-app (v1.0.0) - React Application\nStructure: src/ (45 files), tests/ (12 files), ...\nStatistics: 234 symbols (18 Classes, 42 Functions, 15 Interfaces, ...)" } ] } ``` ``` -------------------------------- ### URI Components Example Source: https://github.com/mizchi/lsmcp/blob/main/docs/lsp-spec.md Illustrates the different components of a Uniform Resource Identifier (URI) as defined by RFC 3986, including scheme, authority, path, query, and fragment. ```plaintext foo://example.com:8042/over/there?name=ferret#nose \_/ \______________/\_________/ \_________/ \__/ | | | | | scheme authority path query fragment | _____________________|__ / \ / \ urn:example:animal:ferret:nose ``` -------------------------------- ### Basic LSMCP Configuration for TypeScript Project Source: https://context7.com/mizchi/lsmcp/llms.txt A basic `.lsmcp/config.json` setup for a TypeScript project using the `tsgo` preset. It defines file patterns to include and basic settings for indexing and watchers. ```json { "$schema": "../node_modules/@mizchi/lsmcp/lsmcp.schema.json", "preset": "tsgo", "files": ["**/*.ts", "**/*.tsx"], "settings": { "autoIndex": true, "indexConcurrency": 5, "enableWatchers": true }, "ignorePatterns": [ "**/node_modules/**", "**/dist/**", "**/.git/**" ] } ``` -------------------------------- ### Search Symbols by Name and Kind (Bash) Source: https://github.com/mizchi/lsmcp/blob/main/docs/ja/introduce-serena-port.md This command searches for symbols within the index. The first example searches for a symbol named 'SymbolIndex' without specifying a kind. The second example searches for symbols named 'Tool' that are of the 'Interface' kind, listing their file paths and line numbers. ```bash # クラスを検索 Found 1 symbol(s): SymbolIndex [Class] src/indexer/core/SymbolIndex.ts:26:1 # インターフェースを検索 $ lsmcp search --name Tool --kind Interface Found 5 symbol(s): CreateToolOptions [Interface] src/core/io/toolFactory.ts:9:1 CreateLSPToolOptions [Interface] src/core/io/toolFactory.ts:93:1 ToolResult [Interface] src/mcp/utils/mcpHelpers.ts:39:1 ToolDef [Interface] src/mcp/utils/mcpHelpers.ts:50:1 CallToolResult [Interface] tests/integration/typescript-lsp.test.ts:15:1 ``` -------------------------------- ### Configure lsmcp with tsgo (Bash) Source: https://github.com/mizchi/lsmcp/blob/main/docs/ja/introduce-serena-port.md This sequence of commands sets up lsmcp for an advanced TypeScript development environment using tsgo. It installs necessary packages as development dependencies, initializes lsmcp with the tsgo preset, and then adds it to Claude Code. ```bash # 開発依存関係としてインストール $ npm add @typescript/native-preview @mizchi/lsmcp@rc -D # lsmcpの設定を初期化(tsgoプリセット) $ npx lsmcp init -p tsgo # Claude Codeに追加 $ claude mcp add lsmcp npx -- lsmcp -p tsgo ``` -------------------------------- ### HLS Project Configuration (Stack) Source: https://github.com/mizchi/lsmcp/blob/main/docs/HASKELL_SETUP.md An `hie.yaml` configuration snippet for HLS projects managed with Stack. This tells HLS to use Stack for project configuration. ```yaml cradle: stack: ``` -------------------------------- ### Report Metadata Example (TypeScript) Source: https://github.com/mizchi/lsmcp/blob/main/docs/memory-report-system.md Illustrates good practice for defining report titles and summaries in TypeScript, emphasizing clarity and descriptiveness. ```typescript // Good title: "Post-OAuth Integration Analysis" summary: "Security audit after implementing OAuth 2.0 flow" // Less useful title: "Report 1" summary: "Project report" ``` -------------------------------- ### Shell Environment Configuration Source: https://github.com/mizchi/lsmcp/blob/main/docs/HASKELL_SETUP.md Adds the ghcup environment script to your shell profile (~/.bashrc, ~/.zshrc) to ensure HLS and GHC are available in your PATH. This needs to be sourced for the current session. ```bash [ -f "$HOME/.ghcup/env" ] && source "$HOME/.ghcup/env" ``` -------------------------------- ### LSMCP Configuration (JSON) Source: https://github.com/mizchi/lsmcp/blob/main/docs/memory-report-system.md Example JSON configuration for enabling advanced memory features in LSMCP, including report retention, auto-generation on merge, and default AI inclusion. ```json { "memoryAdvanced": true, "reportRetentionDays": 90, "autoGenerateOnMerge": false, "defaultIncludeAI": false } ``` -------------------------------- ### lsmcp Performance Configuration Example (JSON) Source: https://github.com/mizchi/lsmcp/blob/main/README.md This JSON snippet illustrates performance-related configuration options for lsmcp. It covers settings such as index concurrency, maximum file size for processing, enabling watchers, and memory limits, allowing for fine-tuning of the tool's performance. ```json { "indexConcurrency": 5, "maxFileSize": 10485760, "enableWatchers": true, "memoryLimit": 1024 } ``` -------------------------------- ### Generate LSMCP Reports (Bash) Source: https://github.com/mizchi/lsmcp/blob/main/docs/memory-report-system.md Examples of generating LSMCP reports using the command-line interface. These commands allow for specifying titles, including AI analysis, and providing custom prompts for targeted insights. ```bash # Generate weekly reports to track project health lsmcp generate_report --title "Weekly Health Check" --include-ai # Create a detailed report before major releases lsmcp generate_report --title "v2.0 Release State" --include-ai --prompt "Focus on breaking changes and migration paths" # Generate report for PR review lsmcp generate_report --title "Feature X Implementation" --summary "Analysis of new authentication system" # Regular debt assessment lsmcp generate_report --include-ai --prompt "Identify technical debt and refactoring opportunities" ``` -------------------------------- ### Initialize lsmcp Onboarding (Command) Source: https://github.com/mizchi/lsmcp/blob/main/docs/ja/introduce-serena-port.md This command initiates the onboarding process for lsmcp. If onboarding has not been run before, it will begin analyzing the project structure and learning relevant information to be saved as memory files. ```shell > start lsmcp onboarding ``` -------------------------------- ### Initialize LSMCP with Go LSP Server Source: https://context7.com/mizchi/lsmcp/llms.txt Initializes LSMCP to integrate with the gopls LSP server for a Go project. The process includes navigating to the project directory and running the init command with gopls as the specified package. ```bash cd go-project npx @mizchi/lsmcp init -p gopls claude mcp add lsmcp-go npx -- -y @mizchi/lsmcp -p gopls ``` -------------------------------- ### Get Hover Information with lsmcp Client Source: https://context7.com/mizchi/lsmcp/llms.txt This code demonstrates how to retrieve hover information (type and documentation) for a symbol at a specific position or text target using the lsmcp client. It shows examples for getting hover info at an exact line and character, and by providing a `textTarget` identifier. The `lsp_get_hover` tool is employed here. ```typescript // Get hover info at exact position const hover = await client.callTool({ name: "lsp_get_hover", arguments: { root: "/path/to/project", relativePath: "src/utils.ts", line: 15, character: 10 } }); // Get hover info by finding text target const hover2 = await client.callTool({ name: "lsp_get_hover", arguments: { root: "/path/to/project", relativePath: "src/utils.ts", line: 15, textTarget: "userName" // Finds and hovers over this identifier } }); // Response example: // { // "message": "Hover information for userName", // "hover": { // "contents": "const userName: string\n\nThe user's display name", // "range": { "start": { "line": 14, "character": 6 }, ... } // } // } ``` -------------------------------- ### Rust Error Example Source: https://github.com/mizchi/lsmcp/blob/main/examples/rust-project/README.md Demonstrates introducing a type error in a Rust program for testing diagnostic capabilities. Uncommenting this line will cause a type mismatch. ```rust let foo: i32 = "xx"; // This will show a type error ``` -------------------------------- ### Initialize Request Example for LSP Communication (JSON) Source: https://github.com/mizchi/lsmcp/blob/main/docs/ja/lsp-spec.md Demonstrates the structure of an 'initialize' request sent from a client to an LSP server. This request contains essential information like the client's process ID, root path, workspace folders, and supported capabilities. It's a crucial part of the LSP handshake. ```json { "jsonrpc": "2.0", "id": 1, "method": "initialize", "params": { "processId": 1234, "rootPath": "/path/to/project", "workspaceFolders": [ { "uri": "file:///path/to/project", "name": "MyProject" } ], "capabilities": { "textDocument": { "completion": { "completionItem": { "snippetSupport": true } } } } } } ``` -------------------------------- ### Explore New Codebase with LSMCP Tools Source: https://github.com/mizchi/lsmcp/blob/main/CLAUDE.md This workflow demonstrates how to start exploring a new codebase using LSMCP tools. It begins with understanding the project structure, then finding relevant classes, and finally diving into the details of a specific class. This approach helps in quickly grasping the project's architecture. ```bash 1. mcp__lsmcp__get_project_overview → Understand structure, main components, statistics 2. mcp__lsmcp__search_symbols --kind "class" → Find all classes in the project 3. mcp__lsmcp__get_symbol_details --symbol "MainClass" → Deep dive into specific class implementation ``` -------------------------------- ### Initialize LSMCP with Python LSP Server Source: https://context7.com/mizchi/lsmcp/llms.txt Initializes LSMCP to work with the pyright LSP server for a Python project. This involves changing to the project directory and executing the init command specifying pyright. ```bash cd python-project npx @mizchi/lsmcp init -p pyright claude mcp add lsmcp-python npx -- -y @mizchi/lsmcp -p pyright ``` -------------------------------- ### Example: Registering for textDocument/willSaveWaitUntil Source: https://github.com/mizchi/lsmcp/blob/main/docs/lsp-spec.md An example JSON-RPC message demonstrating how a server can dynamically register for the 'textDocument/willSaveWaitUntil' capability for JavaScript text documents using the 'client/registerCapability' request. ```json { "method": "client/registerCapability", "params": { "registrations": [ { "id": "79eee87c-c409-4664-8102-e03263673f6f", "method": "textDocument/willSaveWaitUntil", "registerOptions": { "documentSelector": [ { "language": "javascript" } ] } } ] } } ``` -------------------------------- ### Build lsmcp Project Source: https://github.com/mizchi/lsmcp/blob/main/examples/python-project/README.md Builds the lsmcp project using pnpm. This is a prerequisite for testing the Pyright language server integration. ```bash cd ../.. pnpm build ``` -------------------------------- ### Variable Transformation Example Source: https://github.com/mizchi/lsmcp/blob/main/docs/lsp-spec.md Illustrates how to transform variable values using regular expressions and format strings. This example removes the file extension from TM_FILENAME, extracting only the base name. ```text ${TM_FILENAME/(.*)\..+$/$1/} | | | | | | | |-> no options | | | | | |-> references the contents of the first | | capture group | | | |-> regex to capture everything before | the final `.suffix` | |-> resolves to the filename ``` -------------------------------- ### Running Tests with pnpm Source: https://github.com/mizchi/lsmcp/blob/main/CONTRIBUTING.md Provides commands for executing tests using pnpm, including running all tests, specific files, with coverage, and in watch mode. Assumes Vitest is the test runner. ```bash # Run all tests pnpm test # Run specific test file pnpm test path/to/test.ts # Run with coverage pnpm test --coverage # Run in watch mode pnpm test --watch ``` -------------------------------- ### Cloning and Setting Up Upstream Remote Source: https://github.com/mizchi/lsmcp/blob/main/CONTRIBUTING.md Steps to clone the lsmcp repository and configure the upstream remote for contributing. This is a standard procedure for contributing to open-source projects. ```bash git clone https://github.com/your-username/lsmcp.git cd lsmcp git remote add upstream https://github.com/mizchi/lsmcp.git ``` -------------------------------- ### Semantic Token Edit Example Source: https://github.com/mizchi/lsmcp/blob/main/docs/lsp-spec.md An example of a semantic token edit, described in a format similar to text edits. This specifies a change to be applied to the integer array representing semantic tokens. ```json { "start": 0, "deleteCount": 1, "data": [3] } ``` -------------------------------- ### Code Indexer Usage Example - TypeScript Source: https://github.com/mizchi/lsmcp/blob/main/packages/code-indexer/ARCHITECTURE.md Demonstrates how to use the SymbolIndex class from the '@lsmcp/code-indexer' package after refactoring. It shows the creation of a SymbolProvider, instantiation of SymbolIndex with injected dependencies (provider, cache, file system), and basic usage like indexing files and querying symbols. ```typescript // In MCP layer or CLI import { SymbolIndex } from '@lsmcp/code-indexer' import { createLSPSymbolProvider } from '@lsmcp/lsp-client' // Create provider (MCP/CLI responsibility) const provider = createLSPSymbolProvider(lspClient) // Create index with injected provider const index = new SymbolIndex({ provider, cache: new SQLiteCache(rootPath), fileSystem: new NodeFileSystem() }) // Use index await index.indexFiles(['**/*.ts']) const symbols = await index.querySymbols({ name: 'foo' }) ``` -------------------------------- ### GET /get_symbol_details Source: https://context7.com/mizchi/lsmcp/llms.txt Retrieves detailed information about a specific symbol, including its type, definition, and all references. ```APIDOC ## GET /get_symbol_details ### Description Get comprehensive information about a symbol including type, definition, and all references in one call. ### Method GET ### Endpoint /get_symbol_details ### Parameters #### Query Parameters - **root** (string) - Required - The root directory of the project. - **relativePath** (string) - Required - The relative path to the file containing the symbol. - **line** (integer or string) - Required - The line number (1-based) or a string representing the start of the line containing the symbol. - **symbol** (string) - Required - The name of the symbol. ### Request Example ```javascript // Get complete details for a function symbol const details = await client.callTool({ name: "get_symbol_details", arguments: { root: "/path/to/project", relativePath: "src/index.ts", line: 25, // Line number (1-based) symbol: "calculateTotal" } }); // Alternatively, use string matching const details2 = await client.callTool({ name: "get_symbol_details", arguments: { root: "/path/to/project", relativePath: "src/index.ts", line: "function calculateTotal", // Finds line containing this text symbol: "calculateTotal" } }); ``` ### Response #### Success Response (200) - **content** (object) - An object containing detailed information about the symbol, including hover information, definition location, and references. #### Response Example ```json { "content": { "hover": { "contents": "const calculateTotal: (a: number, b: number) => number\n\nCalculates the total of two numbers.", "range": { "start": { "line": 24, "character": 0 }, "end": { "line": 24, "character": 14 } } }, "definition": { "uri": "file:///path/to/project/src/index.ts", "range": { "start": { "line": 24, "character": 0 }, "end": { "line": 24, "character": 14 } }, "text": "function calculateTotal(a: number, b: number): number {" }, "references": [ { "uri": "file:///path/to/project/src/main.ts", "range": { "start": { "line": 10, "character": 10 }, "end": { "line": 10, "character": 22 } } } ] } } ``` ``` -------------------------------- ### Implementation Registration Options (TypeScript) Source: https://github.com/mizchi/lsmcp/blob/main/docs/lsp-spec.md Specifies registration options for the 'Go to Implementation' server capability. It combines text document registration, implementation options, and static registration capabilities. ```typescript export interface ImplementationRegistrationOptions extends TextDocumentRegistrationOptions, ImplementationOptions, StaticRegistrationOptions { } ``` -------------------------------- ### GET /lsp_get_hover Source: https://context7.com/mizchi/lsmcp/llms.txt Retrieves type information and documentation for a symbol at a specific cursor position or text target. ```APIDOC ## GET /lsp_get_hover ### Description Get type information and documentation for a symbol at a specific position. ### Method GET ### Endpoint /lsp_get_hover ### Parameters #### Query Parameters - **root** (string) - Required - The root directory of the project. - **relativePath** (string) - Required - The relative path to the file. - **line** (integer) - Required - The line number (1-based) of the position. - **character** (integer) - Optional - The character number (0-based) of the position. If not provided, `textTarget` must be used. - **textTarget** (string) - Optional - An identifier or text to find on the specified line. If `character` is not provided, this must be used. ### Request Example ```javascript // Get hover info at exact position const hover = await client.callTool({ name: "lsp_get_hover", arguments: { root: "/path/to/project", relativePath: "src/utils.ts", line: 15, character: 10 } }); // Get hover info by finding text target const hover2 = await client.callTool({ name: "lsp_get_hover", arguments: { root: "/path/to/project", relativePath: "src/utils.ts", line: 15, textTarget: "userName" // Finds and hovers over this identifier } }); ``` ### Response #### Success Response (200) - **hover** (object) - An object containing hover information, including contents and the range of the symbol. #### Response Example ```json { "hover": { "contents": "const userName: string\n\nThe user's display name", "range": { "start": { "line": 14, "character": 6 }, "end": { "line": 14, "character": 14 } } } } ``` ``` -------------------------------- ### GET /search_symbols Source: https://context7.com/mizchi/lsmcp/llms.txt Performs a fast symbol search using a pre-built index with automatic incremental updates. ```APIDOC ## GET /search_symbols ### Description Fast symbol search using pre-built index with automatic incremental updates. ### Method GET ### Endpoint /search_symbols ### Parameters #### Query Parameters - **root** (string) - Required - The root directory of the project. - **name** (string) - Optional - The name of the symbol to search for. Can be a partial match. - **kind** (string) - Optional - The type of symbol to search for (e.g., "Class", "Function", "Interface"). ### Request Example ```javascript // Search for all classes named Calculator const result = await client.callTool({ name: "search_symbols", arguments: { root: "/path/to/project", name: "Calculator", kind: "Class" } }); // Search for functions with partial name match const funcResult = await client.callTool({ name: "search_symbols", arguments: { root: "/path/to/project", name: "format", // Matches formatString, formatDate, etc. kind: "Function" } }); // Search all interfaces in the project const interfaces = await client.callTool({ name: "search_symbols", arguments: { root: "/path/to/project", kind: "Interface" } }); ``` ### Response #### Success Response (200) - **content** (array) - An array of text content, each representing a found symbol. #### Response Example ``` Symbol: Calculator (Class) Location: src/utils/calculator.ts:12:14 Container: - ``` ``` -------------------------------- ### LSP Initialization Process Source: https://github.com/mizchi/lsmcp/blob/main/docs/ja/lsp-spec.md Describes the sequence of requests and notifications involved in the initialization of an LSP client and server. ```APIDOC ## LSP Initialization Process The communication between an LSP server and client always begins with an initialization process. 1. **Initialize Request**: The client queries the server for its capabilities. 2. **Initialize Response**: The server responds with its supported capabilities. 3. **Initialized Notification**: Notifies that initialization is complete. ### Initialize Request Example ```json { "jsonrpc": "2.0", "id": 1, "method": "initialize", "params": { "processId": 1234, "rootPath": "/path/to/project", "workspaceFolders": [ { "uri": "file:///path/to/project", "name": "MyProject" } ], "capabilities": { "textDocument": { "completion": { "completionItem": { "snippetSupport": true } } } } } } ``` ``` -------------------------------- ### Initialize LSMCP with Rust LSP Server Source: https://context7.com/mizchi/lsmcp/llms.txt Initializes LSMCP to work with the rust-analyzer LSP server for a Rust project. This involves navigating to the project directory and running the init command with the appropriate package. ```bash cd rust-project npx @mizchi/lsmcp init -p rust-analyzer claude mcp add lsmcp-rust npx -- -y @mizchi/lsmcp -p rust-analyzer ``` -------------------------------- ### LSMCP Integration Test Suite (TypeScript/Vitest) Source: https://context7.com/mizchi/lsmcp/llms.txt A comprehensive integration test suite for LSMCP using TypeScript and Vitest. It covers setting up a temporary project, initializing the LSMCP client, and performing various operations like getting project overviews, searching symbols, retrieving symbol details, and finding references. ```typescript import { describe, it, expect, beforeAll, afterAll } from "vitest"; import { Client } from "@modelcontextprotocol/sdk/client/index.js"; import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js"; import { mkdir, writeFile, rm } from "node:fs/promises"; import { join } from "node:path"; describe("LSMCP Integration Test", () => { let client: Client; let tempDir: string; beforeAll(async () => { // Create test project tempDir = join("/tmp", `test-${Date.now()}`); await mkdir(tempDir, { recursive: true }); await writeFile( join(tempDir, "index.ts"), ` export class Calculator { add(a: number, b: number): number { return a + b; } } export interface Config { apiUrl: string; timeout: number; } ` ); await writeFile( join(tempDir, ".lsmcp/config.json"), JSON.stringify({ files: ["**/*.ts"], settings: { autoIndex: true } }) ); // Start lsmcp server const transport = new StdioClientTransport({ command: "npx", args: ["-y", "@mizchi/lsmcp", "-p", "tsgo"], cwd: tempDir }); client = new Client({ name: "test", version: "1.0.0" }); await client.connect(transport); }, 30000); afterAll(async () => { await client.close(); await rm(tempDir, { recursive: true, force: true }); }); it("should analyze project structure", async () => { const overview = await client.callTool({ name: "get_project_overview", arguments: { root: tempDir } }); expect(overview.content[0].text).toContain("Project Overview"); expect(overview.content[0].text).toContain("Classes"); expect(overview.content[0].text).toContain("Interfaces"); }); it("should search and find symbols", async () => { const result = await client.callTool({ name: "search_symbols", arguments: { root: tempDir, name: "Calculator", kind: "Class" } }); expect(result.content[0].text).toContain("Calculator"); expect(result.content[0].text).toContain("index.ts"); }); it("should get symbol details", async () => { const details = await client.callTool({ name: "get_symbol_details", arguments: { root: tempDir, relativePath: "index.ts", line: 2, symbol: "Calculator" } }); expect(details.content[0].text).toContain("class Calculator"); }); it("should find references", async () => { await writeFile( join(tempDir, "app.ts"), `import { Calculator } from './index';\nconst calc = new Calculator();` ); const refs = await client.callTool({ name: "lsp_find_references", arguments: { root: tempDir, relativePath: "index.ts", line: 2, symbolName: "Calculator" } }); expect(refs.content[0].text).toContain("app.ts"); }); }); ``` -------------------------------- ### Search and Retrieve LSMCP Reports (Bash) Source: https://github.com/mizchi/lsmcp/blob/main/docs/memory-report-system.md Examples of searching and retrieving LSMCP reports using various filters such as keywords, date ranges, and branches. ```bash # Find reports by keyword lsmcp search_reports_by_keyword "performance" # Get reports in date range lsmcp search_reports_by_date --start "2024-01-01" --end "2024-01-31" # Filter by branch lsmcp get_all_reports --branch "main" --limit 20 # Get report history lsmcp get_report_history --limit 10 ``` -------------------------------- ### Test Pyright Language Server Source: https://github.com/mizchi/lsmcp/blob/main/examples/python-project/README.md Tests the Pyright language server integration by running the lsmcp Node.js script with the 'pyright' argument. ```bash node dist/lsmcp.js -p pyright ``` -------------------------------- ### Workspace Management Source: https://github.com/mizchi/lsmcp/blob/main/docs/ja/lsp-spec.md Covers features related to managing multiple project roots and handling configuration changes. ```APIDOC ## Workspace Management ### Workspace Folders Allows for the management of multiple project roots within a workspace. #### Interface `WorkspaceFolder` - **uri** (string) - Required - The URI of the folder. - **name** (string) - Required - The name of the folder. ### Configuration Management Handles the retrieval and notification of configuration settings. #### Get Configuration - **Method**: `workspace/configuration` - **Description**: Request configuration settings from the client. #### Configuration Change Notification - **Method**: `workspace/didChangeConfiguration` - **Description**: Notification sent by the client when configuration settings change. ##### Request Example (Configuration) ```json { "jsonrpc": "2.0", "id": "config-request-id", "method": "workspace/configuration", "params": { "items": [ { "section": "myExtension.settings" } ] } } ``` ``` -------------------------------- ### Notifications and Requests ($/) Source: https://github.com/mizchi/lsmcp/blob/main/docs/lsp-spec.md Explains the convention for protocol implementation-dependent notifications and requests starting with '$/'. Servers and clients can ignore notifications, but must error requests with 'MethodNotFound'. ```APIDOC ## Notifications and Requests ($/) ### Description Messages whose methods start with ‘$/’ are protocol implementation dependent. Servers and clients are free to ignore such notifications. If a server or client receives a request starting with ‘$/’, it must error the request with the error code `MethodNotFound`. ### Method POST (for requests), POST (for notifications) ### Endpoint N/A (This describes message methods, not specific endpoints) ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### Registering for Workspace Folder Changes (JSON) Source: https://github.com/mizchi/lsmcp/blob/main/docs/lsp-spec.md An example of a client registration request for the `workspace/didChangeWorkspaceFolders` notification. This allows servers to receive updates when workspace folders are modified. ```json { id: "28c6150c-bd7b-11e7-abc4-cec278b6b50a", method: "workspace/didChangeWorkspaceFolders" } ``` -------------------------------- ### Example LSP Message Structure Source: https://github.com/mizchi/lsmcp/blob/main/docs/lsp-spec.md Illustrates the typical structure of a message exchanged in the Language Server Protocol, including header fields and the JSON-RPC content part. ```plaintext Content-Length: ...\r\n \r\n { "jsonrpc": "2.0", "id": 1, "method": "textDocument/completion", "params": { ... } } ``` -------------------------------- ### Common Development Commands Source: https://github.com/mizchi/lsmcp/blob/main/CONTRIBUTING.md Provides a list of common development commands for the lsmcp project, including building, testing, linting, type checking, and formatting. ```bash pnpm build # Build the project pnpm test # Run all tests pnpm test:unit # Run unit tests only pnpm test:integration # Run integration tests only pnpm lint # Run linter (oxlint) pnpm typecheck # Type check with tsgo pnpm format # Format code with Biome ```