Skip to main content
Glama
vjsr007
by vjsr007

graph-node-upsert

Create or update graph nodes with labels, types, and properties using MCP Index Notes. Returns node ID for efficient knowledge graph management and relationship mapping.

Instructions

Create or update a graph node with label/type/props. Returns node id.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idNo
labelYes
propsNo
typeNo

Implementation Reference

  • src/mcp.ts:164-168 (registration)
    Tool registration in the tools array defining name, description, and inputSchema.
    {
      name: 'graph-node-upsert',
      description: 'Create or update a graph node with label/type/props. Returns node id.',
      inputSchema: { type: 'object', properties: { id: { type: 'number' }, label: { type: 'string' }, type: { type: 'string' }, props: { type: 'object' } }, required: ['label'] },
    },
  • MCP tool handler that parses input with GraphNodeSchema and calls graph.upsertNode, returning the node ID.
    case 'graph-node-upsert': {
      const parsed = GraphNodeSchema.parse(args);
      const id = graph.upsertNode(parsed);
      return { content: [{ type: 'text', text: JSON.stringify({ id }) }] };
    }
  • Zod schema for validating graph node upsert input: id (opt), label (req), type (opt), props (opt).
    export const GraphNodeSchema = z.object({
      id: z.number().int().positive().optional(),
      label: z.string().min(1),
      type: z.string().optional(),
      props: z.record(z.any()).optional().default({}),
    });
    export type GraphNodeInput = z.infer<typeof GraphNodeSchema>;
  • Core upsertNode implementation in SqliteGraphStore: updates by id or label/type, inserts new if not exists, returns id.
    upsertNode(node: GraphNode): number {
      const props = JSON.stringify(node.props ?? {});
      if (node.id) {
        const info = this.db.prepare(`UPDATE graph_nodes SET label=?, type=?, props=? WHERE id=?`).run(node.label, node.type ?? null, props, node.id);
        if (info.changes === 0) throw new Error(`Node with id ${node.id} not found`);
        return node.id;
      }
      // Try find existing
      const existing = this.getNodeByLabel(node.label, node.type);
      if (existing) {
    this.db.prepare(`UPDATE graph_nodes SET props=? WHERE id=?`).run(props, existing.id);
        return existing.id!;
      }
      const info = this.db.prepare(`INSERT INTO graph_nodes(label, type, props) VALUES (?, ?, ?)`)
        .run(node.label, node.type ?? null, props);
      return Number(info.lastInsertRowid);
    }
  • Core upsertNode implementation in LiteGraphStore (fallback): in-memory upsert by id or label/type, returns id.
    upsertNode(node: GraphNode): number {
      if (node.id) {
        const existing = this.nodes.get(node.id);
        if (!existing) throw new Error(`Node with id ${node.id} not found`);
        const updated = { ...existing, label: node.label, type: node.type, props: node.props ?? existing.props };
        this.nodes.set(node.id, updated);
        this.labelIndex.set(this.keyFor(updated.label, updated.type), node.id);
        return node.id;
      }
      const idxKey = this.keyFor(node.label, node.type);
      const id = this.labelIndex.get(idxKey);
      if (id) {
        const updated = { ...this.nodes.get(id)!, props: node.props ?? this.nodes.get(id)!.props };
        this.nodes.set(id, updated);
        return id;
      }
      const newId = this.nextNodeId++;
      this.nodes.set(newId, { id: newId, label: node.label, type: node.type, props: node.props ?? {} });
      this.labelIndex.set(idxKey, newId);
      return newId;
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the operation ('Create or update') and return value ('Returns node id'), but lacks critical details like whether it's idempotent, what happens on conflicts, permission requirements, or error handling. This is insufficient for a mutation tool with zero annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise and front-loaded, using only one sentence that efficiently conveys the core action and outcome. Every word earns its place, with no redundant or vague phrasing.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (a mutation tool with 4 parameters, nested objects, and no output schema) and lack of annotations, the description is incomplete. It misses essential context like behavioral traits, parameter details, and error handling, making it inadequate for safe and effective use by an AI agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate for undocumented parameters. It lists 'label/type/props' and implies 'id' for updates, but doesn't explain their meanings, formats, or constraints (e.g., what 'props' object should contain, how 'type' relates to 'label'). This adds minimal value beyond the bare schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Create or update') and resource ('graph node') with specific attributes ('label/type/props'), making the purpose unambiguous. However, it doesn't explicitly differentiate from sibling tools like 'graph-import-from-notes' or 'graph-upsert' (if present), which prevents a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives, such as 'graph-import-from-notes' for bulk operations or other graph-related tools. It mentions the return value but offers no context about prerequisites, error conditions, or typical use cases.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/vjsr007/mcp-index-notes'

If you have feedback or need assistance with the MCP directory API, please join our Discord server