Skip to main content
Glama
funwarioisii

Cosense MCP Server

by funwarioisii

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
NameRequiredDescriptionDefault
pageTitleYesTitle of the page

Implementation Reference

  • 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,
          },
        ],
      };
    }
  • 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"],
      },
    },
  • 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;
    }
  • 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,
      };
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/funwarioisii/cosense-mcp-server'

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