
Kiro CLIのLSP対応をPythonで試してみた
クラスメソッド AI駆動開発 Advent Calendar 2025、8日目の記事です!
Kiro CLI が 2025/12/11 公開の v1.22.0 からコードインテリジェンス機能に対応しました。より端的に言えば、VS Codeのように Kiro CLIからも LSP (Language Server Protocol) と連携して、より言語を意識したAIコード開発が可能になりました。
Introducing Code Intelligence, bringing Language Server Protocol (LSP) integration to the Kiro CLI. The agent now has access to the same code understanding that powers Kiro IDE—go-to-definition, find references, hover information, and diagnostics. This enables more accurate code navigation, refactoring suggestions, and context-aware assistance across your entire codebase.
各言語対応のLSPサーバーをローカル環境にインストールし /code init を実行するだけです。
以下では、Pythonを例にLSPサーバーのセットアップ方法と、Kiro CLIでの利用方法を解説します。
LSP対応言語
Language Server Protocol (LSP) は、VS Codeでおなじみの、エディタと言語サーバー間の通信を標準化するプロトコルです。
Kiro CLIは7言語のLSPサーバーをサポートしています。
| 言語 | LSPサーバー | ファイル拡張子 |
|---|---|---|
| Python | pyright | .py |
| Go | gopls | .go |
| TypeScript/JavaScript | typescript-language-server | .ts, .js, .tsx, .jsx |
| Rust | rust-analyzer | .rs |
| Java | jdtls | .java |
| C/C++ | clangd | .c, .cpp, .h, .hpp |
| Ruby | solargraph | .rb |
PythonでのLSPサーバー設定例
以下では、Pythonを例に、LSPサーバーのセットアップ手順を説明します。
1. LSPサーバーのインストール
Pythonの場合、pyrightベースのLSPをインストールします。
以下のいずれかのコマンドを実行しましょう。
npm install -g pyright
pip install pyright
uv tool install pyright
今回は uv でインストールしました。
2. Kiro CLIの起動
プロジェクトで Kiro CLIを起動し /code status を実行し、LSPの状況を確認しましょう。
> /code status
⚠ Workspace not initialized. Run `/code init` to initialize.
Workspace: /Users/taro/kiro/python
Detected Languages: ["python"]
Available LSPs:
○ clangd (cpp) - available
○ gopls (go) - not installed
○ jdtls (java) - not installed
○ pyright (python) - available
○ rust-analyzer (rust) - available
○ solargraph (ruby) - not installed
○ typescript-language-server (typescript) - not installed
Configuration can be updated at .kiro/settings/lsp.json
Learn more at https://kiro.dev/docs/cli/code-intelligence/
Kiro CLIはファイルの拡張子やプロジェクトファイルから、プロジェクト言語を判定します。
上記では
Detected Languages: ["python"]
というようにPythonプロジェクトとして認識されています。
Available LSPs から、どの言語の LSP がインストール済みか確認できます。
○ pyright (python) - available
となっていることから、正しくインストールできていることがわかります。
3. コードインテリジェンスの初期化
/code init を実行してワークスペースのコードインテリジェンスを初期化します。
> /code init
...
◐ pyright (python) - initializing...
...
> /code status
...
✓ pyright (python) - initialized (427ms)
ステータスが initializing から initialized へと変更していれば、LSPサーバーが正しく起動していることを意味します。
4. LSPファイルの確認
カレントディレクトリに .kiro/settings/lsp.json ファイルが追加され、設定ファイルを確認できます。
Pythonの設定例
{
"languages": {
...
"python": {
"name": "pyright",
"command": "pyright-langserver",
"args": [
"--stdio"
],
"file_extensions": [
"py"
],
"project_patterns": [
"pyproject.toml",
"setup.py",
"requirements.txt",
"pyrightconfig.json"
],
"exclude_patterns": [
"**/__pycache__/**",
"**/venv/**",
"**/.venv/**",
"**/.pytest_cache/**"
],
"source_patterns": [],
"multi_workspace": false,
"initialization_options": {},
"request_timeout_secs": 60
},
...
}
例1)Pythonでの型チェック
型エラーを含むPythonコードで動作を確認してみましょう。
サンプルコード
以下の main.py ファイルを用意します。
def greet(name: str) -> str:
return "Hello, " + name
message = greet(123) # 型エラー: str型の引数に int を渡している
診断の実行
Kiro CLIで診断を実行します。
λ > Get diagnostics for main.py
> I'll get the diagnostics for main.py using the code tool.
Getting diagnostics for: /Users/taro/kiro/python-demo/main.py (using tool: code)
Allow this action? Use 't' to trust (always allow) this tool for the session. [y/n/t]:
λ > t
1. Error line 4:17: Argument of type "Literal[123]" cannot be assigned to parameter "name" of type "str" in function "greet"
"Literal[123]" is not assignable to "str"
- Completed in 0.166s
> There's one error in main.py:
Error (Line 4, Column 17-20):
- **Issue**: Argument type mismatch - passing 123 (integer) to greet() function which expects a string parameter
- **Message**: Literal[123] cannot be assigned to parameter name of type str
- **Source**: Pyright (Python type checker)
The function greet() is defined to accept a string parameter, but you're calling it with the integer 123. You need to either:
1. Pass a string: greet("123")
2. Or modify the function to accept integers
▸ Credits: 0.08 • Time: 10s
λ >
期待通りの診断結果が得られました。
例2)Pythonでの定義の調査
サンプルコード
以下の main.py と utils.py の2ファイルを用意します。
main.py
from utils import make_greeting
def greet(name):
message = make_greeting("Kiro User")
utils.py
def make_greeting(name: str) -> str:
return f"Hello, {name}!"
定義の確認
λ > make_greeting の定義は?
> I'll search for the make_greeting function definition in your current directory.
Searching for symbols matching: "make_greeting" (using tool: code)
1. Function make_greeting at utils.py:1:5
- Completed in 0.170s
Going to definition at: utils.py:1:5 (show source) (using tool: code)
utils.py:1:5: def make_greeting(name: str) -> str: | return f"Hello, {name}!"
- Completed in 0.169s
> make_greeting 関数の定義は以下の通りです:
python
def make_greeting(name: str) -> str:
return f"Hello, {name}!"
この関数は utils.py ファイルに定義されており、文字列型の name パラメータを受け取って、"Hello, {name}!" という形式の挨拶文字列を返します。
LSP デバッグ方法
LSPサーバーの動作確認やトラブルシューティングには、以下のコマンドが使えます。
/code init
ワークスペースを初期化します。
λ > /code init
/code status
LSPサーバーのステータスを確認します。
λ > /code status
✓ Workspace initialized
Workspace: /Users/taro/kiro/python-demo
Detected Languages: ["python"]
Project Markers: ["pyproject.toml"]
Available LSPs:
○ clangd (cpp) - available
○ gopls (go) - not installed
○ jdtls (java) - not installed
✓ pyright (python) - initialized (412ms)
○ rust-analyzer (rust) - available
○ solargraph (ruby) - not installed
○ typescript-language-server (typescript) - not installed
Configuration can be updated at .kiro/settings/lsp.json
Learn more at https://kiro.dev/docs/cli/code-intelligence/
/code logs
LSPサーバーのログを確認します。問題が発生した場合の調査に役立ちます。
# Show INFO level 以上のログをダンプ
λ > /code logs -l INFO
2025-12-14T08:34:50.567120Z ERROR ❌ Failed to start LSP server 'pyright': Failed to start language server 'pyright': No such file or directory (os error 2). Ensure it's installed and in PATH.
# 最新10件のログを表示
λ > /code logs -n 10
# 最新10件の DEBUG レベル以上のログを表示
λ > /code logs -l DEBUG -n 10
# ログをファイルにエクスポート
λ > /code logs -l INFO -n 5 -p ./lsp-logs.json
✓ Exported 5 logs to ./lsp-logs.json
LSPサーバープロセスの確認
Kiro CLI spawns LSP server processes in the background that communicate via JSON-RPC over stdio.
念のため、この動作も確認します。
uv で pyright をインストールしている場合、以下の様になりました
$ pstree -w 34857
-+= 34857 taro /Users/taro/.local/share/uv/tools/pyright/bin/python /Users/taro/.local/bin/pyright-langserver --stdio
\--- 34858 taro /Users/taro/.nvm/versions/node/v22.16.0/bin/node /Users/taro/.local/share/uv/tools/pyright/lib/python3.13/site-packages/pyright/dist/langserver.index.js -- --stdio
まとめ
Kiro CLIが主要言語のLSPに対応し、言語とより親和性の高いエージェントコーディングをできるようになりました。
LSPサーバーをインストールし、ワークスペースで /code init を実行するだけです。
ぜひ、お試しください。








