Skip to content

LSP & MCP Providers

Lexicons can provide editor integration through LSP (Language Server Protocol) and MCP (Model Context Protocol) contributions.

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);

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.ts for 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.ts for the AWS hover provider.

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
},
},
];
}
mcpResources() {
return [
{
uri: "chant://lexicon/k8s/catalog",
name: "K8s Resource Catalog",
description: "All available Kubernetes resource types",
handler: async () => {
// Return catalog data
},
},
];
}

Add skills for AI agent guidance, then package and publish your lexicon.