get_page
Retrieve a page from Cosense projects to access documents with titles, descriptions, and interlinked content using bracket notation.
Instructions
Get a page from my-project project on cosen.se
In cosense, a page is a cosense-style document with a title and a description.
Bracket Notation makes links between pages.
Example: [Page Title]
-> "/my-project/Page Title"
A page may have links to other pages.
Links are rendered at the bottom of the page.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pageTitle | Yes | Title of the page |
Implementation Reference
- src/index.ts:126-142 (handler)Handler for the 'get_page' tool in the CallToolRequestSchema. Extracts pageTitle from arguments, fetches the page using getPage helper, formats it, and returns text content.case "get_page": { const pageTitle = String(request.params.arguments?.pageTitle); const page = await getPage(projectName, pageTitle, cosenseSid); if (!page) { throw new Error(`Page ${pageTitle} not found`); } const readablePage = toReadablePage(page); return { content: [ { type: "text", text: readablePage.description, }, ], }; }
- src/index.ts:100-109 (schema)Input schema definition for the 'get_page' tool, specifying pageTitle as required string.inputSchema: { type: "object", properties: { pageTitle: { type: "string", description: "Title of the page", }, }, required: ["pageTitle"], },
- src/index.ts:87-110 (registration)Registration of the 'get_page' tool in the ListToolsRequestSchema response, including name, description, and input schema.{ name: "get_page", description: ` Get a page from ${projectName} project on cosen.se In cosense, a page is a cosense-style document with a title and a description. Bracket Notation makes links between pages. Example: [Page Title] -> "/${projectName}/Page Title" A page may have links to other pages. Links are rendered at the bottom of the page. `, inputSchema: { type: "object", properties: { pageTitle: { type: "string", description: "Title of the page", }, }, required: ["pageTitle"], }, },
- src/cosense.ts:19-37 (helper)Helper function that performs the actual API fetch to retrieve page data from cosen.se.async function getPage( projectName: string, pageName: string, sid?: string, ): Promise<GetPageResponse | null> { const response = sid ? await fetch(`https://cosen.se/api/pages/${projectName}/${pageName}`, { headers: { Cookie: `connect.sid=${sid}` }, }).catch(() => null) : await fetch( `https://cosen.se/api/pages/${projectName}/${pageName}`, ).catch(() => null); if (!response) { return null; } const page = await response.json(); return page as GetPageResponse; }
- src/cosense.ts:39-59 (helper)Helper function to transform raw GetPageResponse into a readable format with title and description including content and links.function toReadablePage(page: GetPageResponse): { title: string; description: string; } { const titleAndDescription = ` ${page.title} --- ${page.lines.map((line) => line.text).join("\n")} `; const relatedPages = page.links.length > 0 ? `## 関連するページのタイトル ${page.links.join("\n")} ` : ""; return { title: page.title, description: titleAndDescription + "\n" + relatedPages, };