Create locate

Finds where a symbol lives: its definition, its references, its type or its implementations, chosen by relation (definition, reference, type, implementation — empty means definition).

POST /v1/lsp/locate

Addresshttps://api.hanzo.ai/v1/lsp/locate
MethodPOST
Operationpost_lsp_locate
AuthAuthorization: Bearer $HANZO_API_KEY

Finds where a symbol lives: its definition, its references, its type or its implementations, chosen by relation (definition, reference, type, implementation — empty means definition).

It resolves THROUGH dependencies. An answer whose external flag is set left the repository, and its path is then the module coordinate it landed in — which is the question a static index cannot answer and this service exists for.

Request

6 fields, body application/json (required).

FieldInTypeRequiredDescription
characterbodyinteger (int64)—Character is a 0-based UTF-16 code-unit offset within Line, per the LSP specification — not a byte offset and not a rune index.
linebodyinteger (int64)—Line is 0-based, per the LSP specification.
pathbodystring—Path is the repo-relative file, e.g. "apps/lsp/lsp.go".
relationbodystring—Relation refines locate: definition, reference, type or implementation.
repobodystring—Repo is the repository NAME within the caller's own org, e.g. "cloud".
revbodystring—Rev is a branch, tag or commit sha.

Response

StatusBodyMeaning
200lsp.Answerok
defaultproblem-detailsrefused

200 body — 44 fields.

FieldInTypeAlwaysDescription
coldbodyboolean—Cold reports that this request paid to PREPARE the revision — the tree write, the dependency fetch and the language server's first index.
completionsbodylsp.Completion[]—Completions is complete's answer: the candidates at the position, typed and resolved through the repository's dependencies rather than guessed from text.
completions[].detailbodystring—Detail is the server's short elaboration, typically the type or signature.
completions[].kindbodyinteger (int64)—Kind is the LSP CompletionItemKind number (2 method, 3 function, 5 field, 6 variable, …), passed through as the protocol spells it.
completions[].labelbodystring—Label is the text a client would insert, and what an editor lists.
diagnosticsbodylsp.Diagnostic[]—Diagnostics is diagnostics' answer: every problem the server finds in the whole file, position ignored.
diagnostics[].codebodyany—Code is the checker's own identifier for the rule, a string or a number depending on the server.
diagnostics[].messagebodystring—Message is the problem in the server's own words, meant to be shown.
diagnostics[].rangebodylsp.Range—
diagnostics[].range.endbodylsp.Position—
diagnostics[].range.end.characterbodyinteger (int64)—Character is a 0-based UTF-16 code-unit offset within Line, per the LSP specification: not a byte offset and not a rune index.
diagnostics[].range.end.linebodyinteger (int64)—Line is 0-BASED, per the LSP specification — one less than the line an editor shows a human.
diagnostics[].range.startbodylsp.Position—
diagnostics[].range.start.characterbodyinteger (int64)—Character is a 0-based UTF-16 code-unit offset within Line, per the LSP specification: not a byte offset and not a rune index.
diagnostics[].range.start.linebodyinteger (int64)—Line is 0-BASED, per the LSP specification — one less than the line an editor shows a human.
diagnostics[].severitybodyinteger (int64)—Severity is the LSP's: 1 error, 2 warning, 3 information, 4 hint.
diagnostics[].sourcebodystring—Source is which checker reported it ("compiler", "go vet", a linter's name), which is what separates a build error from a style opinion.
hoverbodystring—Hover is hover's answer: the type and documentation as the language server itself renders them, so it is prose meant to be shown, not parsed.
langbodystring—Lang is the language the server that answered speaks ("go"), as the daemon reports it.
locationsbodylsp.Location[]—Locations is locate's answer: where the symbol is defined, referenced, typed or implemented, per the relation asked for.
locations[].externalbodyboolean—External is true when the answer left the repository — the case a static index cannot answer, and the reason this service resolves through dependencies.
locations[].pathbodystring—Path is repo-relative while External is false, and the module coordinate ("golang.org/x/[email protected]/semver/semver.go") once it is true.
locations[].rangebodylsp.Range—
locations[].range.endbodylsp.Position—
locations[].range.end.characterbodyinteger (int64)—Character is a 0-based UTF-16 code-unit offset within Line, per the LSP specification: not a byte offset and not a rune index.
locations[].range.end.linebodyinteger (int64)—Line is 0-BASED, per the LSP specification — one less than the line an editor shows a human.
locations[].range.startbodylsp.Position—
locations[].range.start.characterbodyinteger (int64)—Character is a 0-based UTF-16 code-unit offset within Line, per the LSP specification: not a byte offset and not a rune index.
locations[].range.start.linebodyinteger (int64)—Line is 0-BASED, per the LSP specification — one less than the line an editor shows a human.
opbodystring—Op is the question that was asked: hover, locate, symbols, diagnostics or complete.
pathbodystring—Path is the repo-relative file the question was about, echoed back.
repobodystring—Repo is the repository the question was about, echoed back.
revbodystring—Rev is the RESOLVED commit sha, never the branch or tag that was asked for.
symbolsbodylsp.Symbol[]—Symbols is symbols' answer: the file's whole outline, position ignored.
symbols[].detailbodystring—Detail is the server's short elaboration, typically the signature.
symbols[].kindbodyinteger (int64)—Kind is the LSP SymbolKind number (5 class, 6 method, 12 function, 23 struct, …), passed through rather than translated to a word — these callers already speak LSP, and inventing a second vocabulary is how the two drift.
symbols[].namebodystring—Name is the declared identifier.
symbols[].rangebodylsp.Range—
symbols[].range.endbodylsp.Position—
symbols[].range.end.characterbodyinteger (int64)—Character is a 0-based UTF-16 code-unit offset within Line, per the LSP specification: not a byte offset and not a rune index.
symbols[].range.end.linebodyinteger (int64)—Line is 0-BASED, per the LSP specification — one less than the line an editor shows a human.
symbols[].range.startbodylsp.Position—
symbols[].range.start.characterbodyinteger (int64)—Character is a 0-based UTF-16 code-unit offset within Line, per the LSP specification: not a byte offset and not a rune index.
symbols[].range.start.linebodyinteger (int64)—Line is 0-BASED, per the LSP specification — one less than the line an editor shows a human.

Failure carries the platform error shape — see Errors.

Examples

hanzo lsp locate
import { Configuration, LspApi } from 'hanzoai';

const api = new LspApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.postLspLocate({ character: 0, line: 0 });
from hanzoai.cloud import ApiClient, Configuration
from hanzoai.cloud.api import LspApi

client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
result = LspApi(client).post_lsp_locate(character=0, line=0)
cfg := hanzoai.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := hanzoai.NewAPIClient(cfg)

resp, _, err := client.LspAPI.PostLspLocate(context.Background()).Execute()
if err != nil {
	return err
}
use hanzo_client::apis::{configuration::Configuration, lsp_api};

let mut cfg = Configuration::new();
cfg.bearer_access_token = std::env::var("HANZO_API_KEY").ok();

let result = lsp_api::post_lsp_locate(&cfg, Default::default()).await?;
import ai.hanzo.cloud.ApiClient;
import ai.hanzo.cloud.api.LspApi;

ApiClient client = new ApiClient();
client.setBearerToken(System.getenv("HANZO_API_KEY"));

var result = new LspApi(client).postLspLocate();
curl -X POST https://api.hanzo.ai/v1/lsp/locate \
  -H "Authorization: Bearer $HANZO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
       "character": 0,
       "line": 0
     }'

MCP declares no tool for lsp — tools/list on https://api.hanzo.ai/v1/mcp names the products it does reach. Use HTTP or an SDK.


LSP API · All Hanzo APIs · Interactive reference

Was this page useful?