{
  "openapi": "3.1.1",
  "info": {
    "title": "Knotwork Wiki Link Map (Markdown notes) API",
    "version": "1.0.0",
    "summary": "Map the [[links]] between Markdown notes: broken links, orphan pages, hubs and mentions.",
    "description": "Every endpoint performs the same calculation as the human page and returns inputs, result, units, assumptions, sources, warnings and computedAt. MCP endpoint: /mcp."
  },
  "servers": [
    {
      "url": "https://knotworkwikilinkmap.usefulweb.app"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Map the [[links]] between Markdown notes: broken links, orphan pages, hubs and mentions.",
        "description": "Paste Markdown notes that link to each other with [[Page title]] (also [[Page|label]], [[KEY:Page]] and links to other .md files) and @[Name] mentions. The map resolves every link by title, lists broken links to pages that do not exist, orphan pages that nothing links to and nothing links from, the most linked pages and who is mentioned where — with Wikinest’s Markdown reader, the same one Knotwork uses for wiki pages and imported notes.\n\nMethodology:\n- Each note is parsed with Wikinest’s Markdown reader: [[Title]], [[Title|label]], [[KEY:Title]] (the key is dropped when no note has it in its title) and [[Title#heading]] link to the note with that title, compared without case and extra spaces; Markdown links to “name.md” link to the note whose title or file name is “name”.\n- @[Name] mentions become person items. Links to web addresses are counted as external and not followed. Code blocks are not searched for links.\n- Broken links point to a title no note has. Orphans have no link in either direction. Hubs, groups and PageRank come from the knotwork-link-graph analysis.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "knotwork_wikilink_map",
        "x-owner-app": "knotwork",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/KnotworkWikilinkMapInput"
              },
              "examples": {
                "example1": {
                  "summary": "Team wiki with a broken link and an orphan page",
                  "value": {
                    "notes": "=== Onboarding\nStart with [[Team handbook]] and [[Tools we use]]. Ask @[Ana Silva] for access.\n=== Team handbook\nHow we work: see [[Meeting rules]] and [[Release process]].\n=== Release process\nChecklist in [[Tools we use]]. Owner: @[Ben Okafor]. Old notes: [[Release 2025]].\n=== Tools we use\nIssue tracker, chat and the wiki. Back to [[Onboarding]].\n=== Meeting rules\nShort, with an agenda.\n=== Parking\nGarage on level -2."
                  }
                },
                "example2": {
                  "summary": "Notes with # headings and a link to another .md file",
                  "value": {
                    "notes": "# Ideas\nSee [[Reading list]] and [details](plans.md).\n# Reading list\nBack to [[Ideas]].\n# Plans\nNothing yet."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KnotworkWikilinkMapResult"
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON body.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "Invalid input (see errors[]).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded (see Retry-After).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tool": {
      "get": {
        "operationId": "getToolDefinition",
        "summary": "Inputs, output schema and examples for this tool",
        "responses": {
          "200": {
            "description": "Tool definition.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Problem": {
        "type": "object",
        "description": "RFC 9457 problem details. 422 responses include per-field `errors`.",
        "required": [
          "type",
          "title",
          "status",
          "detail"
        ],
        "properties": {
          "type": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "integer"
          },
          "detail": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "field",
                "message"
              ],
              "properties": {
                "field": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "KnotworkWikilinkMapInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "notes": {
            "title": "Notes (each starts with a line “=== Title”)",
            "description": "Without any “=== Title” line, “# Title” headings start the notes. Links match titles case-insensitively.",
            "type": "string",
            "maxLength": 4000000,
            "default": "=== Onboarding\nStart with [[Team handbook]] and [[Tools we use]]. Ask @[Ana Silva] for access.\n=== Team handbook\nHow we work: see [[Meeting rules]] and [[Release process]].\n=== Release process\nChecklist in [[Tools we use]]. Owner: @[Ben Okafor]. Old notes: [[Release 2025]].\n=== Tools we use\nIssue tracker, chat and the wiki. Back to [[Onboarding]].\n=== Meeting rules\nShort, with an agenda.\n=== Parking\nGarage on level -2."
          },
          "top": {
            "title": "Show the top hubs",
            "type": "number",
            "minimum": 1,
            "maximum": 100,
            "default": 10
          }
        },
        "required": [
          "notes"
        ]
      },
      "KnotworkWikilinkMapResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "schemaVersion",
          "tool",
          "computedAt",
          "inputs",
          "summary",
          "result",
          "units",
          "assumptions",
          "sources",
          "warnings",
          "presentation",
          "links"
        ],
        "properties": {
          "schemaVersion": {
            "type": "string",
            "const": "1.0"
          },
          "tool": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "name",
              "version"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            }
          },
          "computedAt": {
            "type": "string",
            "format": "date-time"
          },
          "inputs": {
            "type": "object",
            "description": "Normalised inputs actually used, including applied defaults."
          },
          "summary": {
            "type": "string"
          },
          "result": {
            "type": "object",
            "required": [
              "pages",
              "links",
              "broken",
              "graph",
              "analysis"
            ],
            "properties": {
              "pages": {
                "type": "integer"
              },
              "links": {
                "type": "integer",
                "description": "Wiki and .md links found (resolved or not)."
              },
              "mentions": {
                "type": "integer"
              },
              "external": {
                "type": "integer"
              },
              "broken": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "fromTitle": {
                      "type": "string"
                    },
                    "target": {
                      "type": "string"
                    }
                  }
                }
              },
              "duplicateTitles": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "graph": {
                "type": "object",
                "description": "nodes (page:N, person:N) and edges (kind link or mention) — open it in Knotwork or the link graph analyser."
              },
              "analysis": {
                "type": "object",
                "description": "Same report as knotwork-link-graph (people are not counted as hubs or orphans)."
              }
            }
          },
          "units": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "assumptions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "title"
              ],
              "properties": {
                "title": {
                  "type": "string"
                },
                "url": {
                  "type": "string"
                },
                "publisher": {
                  "type": "string"
                },
                "retrievedAt": {
                  "type": "string"
                },
                "note": {
                  "type": "string"
                }
              }
            }
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "presentation": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "Display blocks used by the human page (same data)."
          },
          "links": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "human",
              "api",
              "openapi",
              "methodology"
            ],
            "properties": {
              "human": {
                "type": "string",
                "format": "uri"
              },
              "api": {
                "type": "string",
                "format": "uri"
              },
              "openapi": {
                "type": "string",
                "format": "uri"
              },
              "methodology": {
                "type": "string",
                "format": "uri"
              }
            }
          }
        }
      }
    }
  }
}