Kest

Search

Search the documentation

MCP

Primitives

Tools, resources and prompts.

MCP has three building blocks. Choosing the right one makes your server easy for an assistant to use.

PrimitiveAnnotationWhat it isThink of it as
Tool@McpTool(name, description, readOnly, destructive)an action the assistant can call, with typed argumentsa function call
Resource@McpResource(uri, name, mimeType, description)data the assistant can read, at a fixed URIa document
Prompt@McpPrompt(name, description)a reusable prompt template, with argumentsa saved question
@Injectable
class Inventory(private val repo: ProductRepository) {
 
    @McpTool("restock", "Adds stock to a product. Changes data.", destructive = false)
    fun restock(sku: String, amount: Int, note: String?): String { repo.add(sku, amount); return "restocked $sku by $amount" }
 
    @McpTool("find_product", "Looks a product up by SKU", readOnly = true)
    fun find(sku: String): Product? = repo.findBySku(sku)
 
    @McpResource("inventory://low-stock", "Low stock", "application/json", "Products with fewer than 10 left")
    fun lowStock(): List<Product> = repo.lowStock()
 
    @McpPrompt("restock_plan", "Drafts a restock plan")
    fun plan(category: String) = "Plan a restock for $category using the inventory://low-stock resource."
}

Tools

Parameter names and types become the tool's JSON schema; non-nullable parameters are required (make one nullable, note: String?, to make it optional: Kotlin defaults are not visible), enums list their values, lists become arrays. A tool's return value is sent as text (JSON for objects). A tool that throws is reported as isError.

Set the hints honestly: readOnly = true for lookups, destructive = true for deletes or irreversible changes. Assistants use them to decide when to ask the human first.

Resources

Data the assistant reads rather than calls: a document, a report, a config. Each has a fixed URI (inventory://low-stock) and a MIME type (application/json by default). Use resources for reference data that does not need arguments.

Prompts

A prompt is a template the user picks in their assistant ("Restock plan for ..."). It returns text (a plain String becomes one user message) or several PromptMessage(role, text) messages. They guide the assistant to use your tools and resources well.

Which to choose

  • Needs arguments or changes something → tool.
  • A fixed piece of data to read → resource.
  • A starting question for people → prompt.

Not supported: resource templates (URIs with parameters) and subscriptions.

Read more