bst-avl-mcp
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@bst-avl-mcpInsert 3, 1, 2 into AVL tree and visualize rotations"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Educational MCP server to learn BST & AVL trees
A Model Context Protocol (MCP) server designed to help you learn and visualize Binary Search Trees (BST) and AVL Trees. This project implements these data structures in TypeScript, demonstrating core algorithms like insertion, deletion, and AVL rotations.
Features
Binary Search Tree (BST): Standard implementation.
AVL Tree: Self-balancing binary search tree with automatic rotations (Left, Right, Left-Right, Right-Left).
Visualization: Tools to print the tree structure to the console/client to see how it changes after operations.
Educational Tools: Explicitly designed to help users "hand trace" or visualize specific tree states.
Related MCP server: GitViz MCP
Installation
Clone the repository.
Install dependencies:
npm install
Usage
Building the Server
Compile the TypeScript code:
npm run buildRunning the Server
Start the MCP server (stdio transport):
npm startRunning Verification Tests
Run the included test script which demonstrates a sequence of insertions and rotations (based on a classic hand-tracing example):
npm testUsing with Claude Desktop
To use this server with the Claude Desktop app, add the following configuration to your claude_desktop_config.json file:
{
"mcpServers": {
"bst-avl": {
"command": "node",
"args": [
"/YourDirectory/bst-avl-mcp/build/index.js"
]
}
}
}Note: Update the path to match your project location.
Available Tools
reset_tree: Resets the specified tree (bstoravl) to be empty.insert_node: Inserts a number into the tree and returns the new visual structure.delete_node: Deletes a number from the tree and maintains balance (for AVL).search_node: Checks if a number exists in the tree.print_tree: Returns a string representation of the current tree hierarchy.
Project Structure
src/bst.ts: Basic BST implementation.src/avl.ts: AVL Tree implementation with rotation logic.src/index.ts: MCP Server entry point.src/types.ts: Shared TypeScript interfaces.
Available Tools
5 toolsdelete_nodeC
Delete a key from the specified tree.
| Name | Required | Description | Default |
|---|---|---|---|
| key | Yes | The integer key to delete | |
| treeType | Yes | The type of tree to delete from |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the full behavioral burden for a destructive mutation, yet it says nothing about irreversibility, what happens if the key is absent (error vs silent no-op), or whether an AVL tree rebalances after removal. These are exactly the traits an agent needs before calling a delete.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
A single short sentence with the action front-loaded and no filler. It is efficient, though the terseness contributes to the missing behavioral detail rather than reflecting deliberate economy.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a two-parameter destructive tool with no annotations and no output schema, the description should at minimum say what is returned or what occurs when the key is not found, and it does not. An agent could invoke it but cannot predict the outcome.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100% and the enum on treeType ('bst'/'avl') is self-documenting, so the schema does the heavy lifting. The description adds no format or constraint detail beyond what is already structured, which is the baseline-3 case.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
States a specific verb ('Delete') and resource ('a key from the specified tree'), so the operation is unambiguous. It does not, however, differentiate itself from sibling reset_tree, which also removes data, leaving the agent to infer that this deletes one key rather than clearing the tree.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No guidance on when to use this versus reset_tree (bulk removal) or on prerequisites such as the key existing in the tree. Usage must be inferred entirely from the name.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
insert_nodeC
Insert a key into the specified tree.
| Name | Required | Description | Default |
|---|---|---|---|
| key | Yes | The integer key to insert | |
| treeType | Yes | The type of tree to insert into |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the full behavioral burden, yet it says nothing about duplicate-key handling, whether the tree is mutated in place, rebalancing for avl, or error behavior. 'Insert' implies mutation but the details an agent needs are absent.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
A single short sentence that is front-loaded with the action and free of filler. It is efficient, though the brevity edges into under-specification rather than optimal density.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a mutation tool with no annotations and no output schema, the description should at least indicate the effect (tree modified) and any return or duplicate semantics. Given the simple two-parameter schema, that required context is missing.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, so both parameters (key, treeType) are already documented in the schema, including the bst/avl enum. The description adds no syntax, range, or semantics beyond the schema, so the baseline 3 applies.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
States a specific verb (insert) plus the resource (a key) and target (tree), which cleanly distinguishes it from delete_node, search_node, print_tree and reset_tree without needing the schema. It does not explicitly name or contrast with siblings, so it stops short of a 5.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
There is no statement of when to use this rather than delete_node or search_node, no prerequisites, and no mention of what treeType must already exist. The description offers no usage context at all.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
print_treeB
Get a visual representation of the tree structure.
| Name | Required | Description | Default |
|---|---|---|---|
| treeType | Yes | The type of tree to print |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the full burden. It implies a read-only operation ('Get') and discloses the return is a visual representation of the structure, which is useful. However, it does not confirm non-destructiveness or describe output format beyond the vague 'visual representation'.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
A single efficient sentence with no filler and the core purpose front-loaded. Nothing is wasted, though it is minimal enough that brevity borders on under-specification.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a simple one-parameter tool with full schema coverage and no output schema, the description is minimally adequate. It omits any guidance on usage relative to siblings, which is the main gap.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100% and the treeType enum (bst/avl) is fully documented in the schema. The description adds no additional meaning about the parameter, so the baseline 3 applies.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
States a specific verb ('Get a visual representation') and resource ('the tree structure'), making the operation clear. It does not, however, differentiate from siblings like search_node or how the visual output differs from other query tools.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No indication of when to use this tool versus alternatives such as search_node or the mutation siblings. The agent is left to infer that this is a read-only inspection tool purely from the name.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
reset_treeA
Reset the specified tree (bst or avl) to be empty.
| Name | Required | Description | Default |
|---|---|---|---|
| treeType | Yes | The type of tree to reset |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full behavioral burden. It states the resulting state ('to be empty'), which is useful, but doesn't disclose whether this operation is reversible, whether it can fail, or what it returns. Adequate disclosure of the outcome, but not the surrounding behavior.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
A single, well-structured sentence with zero waste. The action, target, and resulting state are all front-loaded and unambiguous.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a simple one-param mutation tool with no annotations or output schema, the description states the core effect but omits behavioral context (permissions, idempotency, error cases). It is minimally complete but leaves the agent without information about anything beyond the resulting state.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100% and the single enum parameter is fully self-documenting in the schema. The description mentions 'bst or avl' but adds no syntactic or format detail beyond the schema, so the baseline of 3 applies.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
States a specific verb (reset) and resource (tree), and specifies the target state (empty). Distinguishes itself from siblings like insert_node, delete_node, and search_node, which are all value-level operations rather than wholesale resets.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The usage is implied and clear (reset a whole tree), but the description provides no explicit when-to-use guidance or contrast with alternatives like delete_node, which deletes a single node. No exclusions are stated.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
search_nodeC
Search for a key in the specified tree.
| Name | Required | Description | Default |
|---|---|---|---|
| key | Yes | The integer key to search for | |
| treeType | Yes | The type of tree to search in |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full behavioral burden. It doesn't say whether the search mutates the tree, what it returns on a miss, or whether it requires prior insert_node calls. Only the implicit non-destructive nature of 'search' gives any signal.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
A single, front-loaded sentence with no wasted words. It is efficiently sized, though it is arguably too terse for the information an agent needs.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
With no output schema, the description should explain the return value (found/not found, node or boolean), which it omits entirely. For a lookup tool whose whole value is the result, this is a meaningful gap.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100% — both 'key' (integer to search for) and 'treeType' (enum bst/avl) are documented in the schema. The description adds no format or semantics beyond that, so the baseline of 3 applies.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
States a specific verb ('Search') and resource ('a key in the specified tree'), so the agent can tell it apart from insert_node, delete_node, reset_tree and print_tree by action. It does not explicitly name the siblings, but the verb is unambiguous among them.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
There is no guidance on when to use this tool versus alternatives, no mention of preconditions (does the tree need to exist?), and no exclusions. Usage is only implied by the verb.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
5 tool updates
v1.0.0- First observed
delete_node - First observed
insert_node - First observed
print_tree - First observed
reset_tree - First observed
search_node
TDQS
Scored across 5 tools
Each tool performs a distinct operation on the tree: reset, insert, delete, search, and print. No two tools overlap in purpose, making selection unambiguous.
All tool names follow a consistent verb_noun pattern (reset_tree, insert_node, delete_node, search_node, print_tree). The convention is predictable and easy to read.
Five tools are well-scoped for a BST/AVL tree server, covering the essential operations without bloat. Each tool clearly earns its place.
The surface covers the core lifecycle: reset, insert, delete, search, and visualize. Minor gaps exist for auxiliary queries like tree height, size, or traversal order, but these are not essential for basic tree manipulation.
Maintenance
Related MCP Connectors
Educational MCP server with 17 math/stats tools, visualizations, and persistent workspace
Design domain models and generate deterministic multi-stack code, driven by your coding agent.
Search and read ~95,000 interactive concept diagrams that explain how things work — visually.
Create and edit collaborative architecture diagrams with any AI assistant using the Trident 2D DSL.
Related MCP Servers
- AlicenseCqualityDmaintenanceDeep directory tree visualization tool enabling efficient visualization of complex directory structures with AI-powered analysis capabilities.16 npm14MIT
- AlicenseNot gradedqualityBmaintenanceVisualizes Git history and commit logs with before/after animations for operations like merge, rebase, and cherry-pick. Integrates with AI assistants to provide Git analysis tools and smart command suggestions through natural language.1MIT
- FlicenseNot gradedqualityDmaintenanceEnables AI models to generate interactive, clickable code walkthrough diagrams using Mermaid code and node descriptions. It provides a web interface for viewing, persisting, and sharing these diagrams via a local database and a dedicated share server.5 npm3-
- FlicenseBqualityDmaintenanceTransforms markdown documents into immersive 3D visualizations using semantic analysis and spatial layout, enabling navigable knowledge structures.72-