LSP & MCP Providers
Lexicons can provide editor integration through LSP (Language Server Protocol) and MCP (Model Context Protocol) contributions.
LSP Providers
Section titled “LSP Providers”Core provides LexiconIndex, lexiconCompletions, and lexiconHover — generic implementations that work with any lexicon’s registry data:
import { LexiconIndex, lexiconCompletions, lexiconHover } from "@intentius/chant/lsp/lexicon-providers";
const index = new LexiconIndex(lexiconData);
// In your completionProvider():return lexiconCompletions(ctx, index, "My resource");
// In your hoverProvider():return lexiconHover(ctx, index, myCustomHoverFormatter);Completions
Section titled “Completions”The completionProvider() method on your plugin returns completion items for resource and property type names. Use lexiconCompletions to generate standard completions from your registry:
completionProvider(ctx) { return lexiconCompletions(ctx, index, "K8s resource");}See
lexicons/aws/src/lsp/completions.tsfor the AWS completion provider.
The hoverProvider() method returns hover information when users mouse over resource type constructors. Use lexiconHover with an optional custom formatter:
hoverProvider(ctx) { return lexiconHover(ctx, index, (className, entry) => { return { contents: `**${className}** — \`${entry.resourceType}\`` }; });}See
lexicons/aws/src/lsp/hover.tsfor the AWS hover provider.
MCP Contributions
Section titled “MCP Contributions”Lexicons can contribute MCP tools and resources for AI agent integration:
mcpTools() { return [ { name: "lookup-resource", description: "Look up a resource type definition", inputSchema: { type: "object", properties: { name: { type: "string" } } }, handler: async (input) => { // Return resource type info }, }, ];}Resources
Section titled “Resources”mcpResources() { return [ { uri: "chant://lexicon/k8s/catalog", name: "K8s Resource Catalog", description: "All available Kubernetes resource types", handler: async () => { // Return catalog data }, }, ];}Next Steps
Section titled “Next Steps”Add skills for AI agent guidance, then package and publish your lexicon.