{
  "openapi": "3.1.1",
  "info": {
    "title": "Knotwork Link Suggestion Finder API",
    "version": "1.0.0",
    "summary": "Find notes that mention another note by name but do not link to it yet — and add the [[links]].",
    "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://knotworklinksuggestions.usefulweb.app"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Find notes that mention another note by name but do not link to it yet — and add the [[links]].",
        "description": "Paste Markdown notes and the finder lists every place where one note names another note (or one of your extra titles) without a [[link]]: which note, which title, the words as written, how often and a short context. Matching is by whole words, ignores case and accents, handles titles of several words, scripts without spaces such as Chinese or Thai and Korean particles, and skips titles that are too short or too common. You also get the notes back with the first mention of each suggestion turned into a [[link]] — the same engine as Knotwork’s “Suggested links”.\n\nMethodology:\n- Notes and titles are split into words and normalised the same way: Unicode NFKC, lower case, accents removed for Latin, Greek and Cyrillic letters (é → e, ß → ss), Arabic vowel marks and Hebrew points removed. Indic vowel signs stay because they are part of the letters.\n- A title matches only complete words in the same order, with any spaces or punctuation between them (“checkout-redesign” matches “Checkout redesign”, “Atlas” does not match “Atlases”). At each position the longest matching title wins. Chinese, Japanese, Thai, Lao, Khmer and Myanmar text has no spaces, so it is compared character by character; a Korean title may be followed by a particle (회의록을).\n- Titles shorter than the minimum, numbers alone, common words (“Notes”, “Todo”, “the” … in seven languages) and titles that occur in more than 5 % of at least 20 notes are not suggested. A note never suggests itself; notes that already link to each other with [[…]] (in either direction) are skipped.\n- Score 0.05–1: 0.4, plus 0.15 per extra word (up to 3), 0.1 for names of 8 letters or more and 0.1 per repeated mention (up to 3), minus 0.2 when several notes share the name. Each text is read once with a word trie, so the cost grows with the length of the notes; at most 4,000,000 characters are searched.\n- The linked notes replace the first mention of each suggestion that points to exactly one title with [[Title]] (or [[Title|words as written]]).",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "knotwork_link_suggestions",
        "x-owner-app": "knotwork",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/KnotworkLinkSuggestionsInput"
              },
              "examples": {
                "example1": {
                  "summary": "Team wiki: unlinked mentions of other notes and of two extra pages",
                  "value": {
                    "notes": "=== Onboarding\nStart with the Team handbook. Ask Ana for access to the tools we use.\n=== Team handbook\nHow we work: meeting rules, the release process and our [[Glossary]].\n=== Release process\nEvery second Tuesday. Run the deployment checklist first; the Release Process page is the source of truth.\n=== Meeting rules\nShort, with an agenda. Decisions go to the decision log.\n=== Glossary\nWords we use. See the team handbook.\n=== Tools we use\nIssue tracker, chat and the wiki.",
                    "titles": "Decision log | decisions\nDeployment checklist"
                  }
                },
                "example2": {
                  "summary": "Notes in German with accents and # headings",
                  "value": {
                    "notes": "# Übergabe\nDie Checkliste für den Releaseprozess liegt im Wiki, siehe auch Qualitätssicherung.\n# Releaseprozess\nJeden zweiten Dienstag.\n# Qualitätssicherung\nTests vor jedem Release.",
                    "titles": ""
                  }
                },
                "example3": {
                  "summary": "Chinese and Japanese notes (no spaces between words)",
                  "value": {
                    "notes": "=== 会议记录\n下次讨论项目计划。\n=== 项目计划\n第一阶段。\n=== メモ\n会議記録はここ。\n=== 会議記録\n毎週。",
                    "titles": ""
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KnotworkLinkSuggestionsResult"
                }
              }
            }
          },
          "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"
                }
              }
            }
          }
        }
      },
      "KnotworkLinkSuggestionsInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "notes": {
            "title": "Notes (each starts with a line “=== Title”)",
            "description": "Without any “=== Title” line, “# Title” headings start the notes. Existing [[links]], code and web addresses are not searched.",
            "type": "string",
            "maxLength": 4000000,
            "default": "=== Onboarding\nStart with the Team handbook. Ask Ana for access to the tools we use.\n=== Team handbook\nHow we work: meeting rules, the release process and our [[Glossary]].\n=== Release process\nEvery second Tuesday. Run the deployment checklist first; the Release Process page is the source of truth.\n=== Meeting rules\nShort, with an agenda. Decisions go to the decision log.\n=== Glossary\nWords we use. See the team handbook.\n=== Tools we use\nIssue tracker, chat and the wiki."
          },
          "titles": {
            "title": "More titles to look for (optional, one per line)",
            "description": "Pages that are not in the pasted notes, e.g. other pages of your wiki. Other names of the same page after a | sign.",
            "type": "string",
            "maxLength": 200000,
            "default": ""
          },
          "minChars": {
            "title": "Ignore titles shorter than (letters)",
            "description": "Scripts written without spaces (Chinese, Japanese, Thai …) need at least 2 characters.",
            "type": "number",
            "minimum": 1,
            "maximum": 20,
            "default": 3
          },
          "perNote": {
            "title": "Suggestions per note (at most)",
            "type": "number",
            "minimum": 1,
            "maximum": 200,
            "default": 20
          }
        },
        "required": [
          "notes"
        ]
      },
      "KnotworkLinkSuggestionsResult": {
        "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": [
              "notes",
              "names",
              "suggestions",
              "linkedNotes",
              "added",
              "stats"
            ],
            "properties": {
              "notes": {
                "type": "integer"
              },
              "names": {
                "type": "integer",
                "description": "Distinct names searched (titles and other names that were not too short or too common)."
              },
              "suggestions": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "from": {
                      "type": "string"
                    },
                    "to": {
                      "type": "string"
                    },
                    "fromTitle": {
                      "type": "string"
                    },
                    "toTitle": {
                      "type": "string"
                    },
                    "matched": {
                      "type": "string"
                    },
                    "count": {
                      "type": "integer"
                    },
                    "score": {
                      "type": "number"
                    },
                    "snippet": {
                      "type": "string"
                    },
                    "offset": {
                      "type": "integer"
                    },
                    "span": {
                      "type": "integer"
                    },
                    "ambiguous": {
                      "type": "boolean"
                    }
                  }
                }
              },
              "linkedNotes": {
                "type": "string",
                "description": "The notes with the first mention of each unambiguous suggestion turned into a [[link]]."
              },
              "added": {
                "type": "integer"
              },
              "stats": {
                "type": "object"
              }
            }
          },
          "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"
              }
            }
          }
        }
      }
    }
  }
}