Skip to main content
Glama

plsreadme_share_file

Read-only

Transform a local markdown file into a shareable web link. Uploads the file, returns a permanent URL, and updates any existing link for the same file.

Instructions

Share a local markdown file as a clean, readable web link on plsreadme.com.

Reads the file, uploads it, and returns a permanent shareable URL. If the file was previously shared, updates the existing link instead of creating a new one.

Tracks links in a local .plsreadme file for future edits and deletes.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYesPath to the markdown file to share (relative or absolute).

Implementation Reference

  • The main handler function for the 'plsreadme_share_file' tool. It reads a local markdown file, checks for existing records to update, otherwise creates a new share, and saves the record locally.
    async ({ file_path }) => {
      const absolutePath = resolve(process.cwd(), file_path);
    
      let markdown: string;
      try {
        markdown = readFileSync(absolutePath, 'utf-8');
      } catch (err) {
        const code = (err as NodeJS.ErrnoException).code;
        if (code === 'ENOENT') return formatError(`File not found: ${file_path}\nTried: ${absolutePath}`);
        if (code === 'EACCES') return formatError(`Permission denied: ${file_path}`);
        return formatError(`Could not read file: ${(err as Error).message}`);
      }
    
      if (markdown.length > MAX_FILE_SIZE) return formatError(`File too large (${Math.round(markdown.length / 1024)}KB). Max ${MAX_FILE_SIZE / 1024}KB.`);
      if (markdown.trim().length === 0) return formatError(`File is empty: ${file_path}`);
    
      try {
        // Check if already shared — update instead of creating new
        const existing = getRecordBySource(file_path) || getRecordBySource(absolutePath);
        if (existing) {
          await apiUpdate(existing.id, existing.admin_token, markdown);
          const title = extractTitle(markdown) || basename(file_path, '.md');
          existing.title = title;
          saveRecord(existing);
          return formatSuccess(title, existing.url, existing.raw_url, '♻️ Updated existing link (same URL).');
        }
    
        const result = await apiCreate(markdown);
        const title = extractTitle(markdown) || basename(file_path, '.md');
    
        saveRecord({
          id: result.id,
          url: result.url,
          raw_url: result.raw_url,
          admin_token: result.admin_token,
          title,
          source: file_path,
          created_at: new Date().toISOString(),
        });
    
        const gitWarn = checkGitignore();
        return formatSuccess(
          title,
          result.url,
          result.raw_url,
          gitWarn || undefined
        );
      } catch (err) {
        return formatError((err as Error).message);
      }
    }
  • Registration of the 'plsreadme_share_file' tool on the MCP server via server.tool(), including description, schema (file_path parameter), and metadata (title, hints).
    // Tool: Share a file
    server.tool(
      'plsreadme_share_file',
      `Share a local markdown file as a clean, readable web link on plsreadme.com.
    
    Reads the file, uploads it, and returns a permanent shareable URL. If the file was previously shared, updates the existing link instead of creating a new one.
    
    Tracks links in a local .plsreadme file for future edits and deletes.`,
      {
        file_path: z.string().describe('Path to the markdown file to share (relative or absolute).'),
      },
      {
        title: 'Share Markdown File',
        readOnlyHint: true,
        destructiveHint: false,
        idempotentHint: false,
        openWorldHint: true,
      },
      async ({ file_path }) => {
        const absolutePath = resolve(process.cwd(), file_path);
    
        let markdown: string;
        try {
          markdown = readFileSync(absolutePath, 'utf-8');
        } catch (err) {
          const code = (err as NodeJS.ErrnoException).code;
          if (code === 'ENOENT') return formatError(`File not found: ${file_path}\nTried: ${absolutePath}`);
          if (code === 'EACCES') return formatError(`Permission denied: ${file_path}`);
          return formatError(`Could not read file: ${(err as Error).message}`);
        }
    
        if (markdown.length > MAX_FILE_SIZE) return formatError(`File too large (${Math.round(markdown.length / 1024)}KB). Max ${MAX_FILE_SIZE / 1024}KB.`);
        if (markdown.trim().length === 0) return formatError(`File is empty: ${file_path}`);
    
        try {
          // Check if already shared — update instead of creating new
          const existing = getRecordBySource(file_path) || getRecordBySource(absolutePath);
          if (existing) {
            await apiUpdate(existing.id, existing.admin_token, markdown);
            const title = extractTitle(markdown) || basename(file_path, '.md');
            existing.title = title;
            saveRecord(existing);
            return formatSuccess(title, existing.url, existing.raw_url, '♻️ Updated existing link (same URL).');
          }
    
          const result = await apiCreate(markdown);
          const title = extractTitle(markdown) || basename(file_path, '.md');
    
          saveRecord({
            id: result.id,
            url: result.url,
            raw_url: result.raw_url,
            admin_token: result.admin_token,
            title,
            source: file_path,
            created_at: new Date().toISOString(),
          });
    
          const gitWarn = checkGitignore();
          return formatSuccess(
            title,
            result.url,
            result.raw_url,
            gitWarn || undefined
          );
        } catch (err) {
          return formatError((err as Error).message);
        }
      }
    );
  • Input schema for the tool: file_path (string) describing the path to the markdown file to share.
    {
      file_path: z.string().describe('Path to the markdown file to share (relative or absolute).'),
    },
  • getRecordBySource() - finds an existing record by source file path, used to determine if we should update instead of create.
    function getRecordBySource(source: string): DocRecord | undefined {
      const abs = resolve(process.cwd(), source);
      return loadRecords(findRecordFile()).find(
        (r) => r.source === source || r.source === abs
      );
    }
  • API helpers: apiCreate() and apiUpdate() - functions that call the plsreadme.com API to create or update shared documents.
    async function apiCreate(markdown: string): Promise<CreateResponse> {
      const auth = getLocalAuthState();
      if (auth.mode === 'missing') {
        throw new Error(auth.summary);
      }
    
      const response = await fetch(PLSREADME_API, {
        method: 'POST',
        headers: {
          'Content-Type': 'application/json',
          ...(auth.apiKey ? { Authorization: `Bearer ${auth.apiKey}` } : {}),
        },
        body: JSON.stringify({ markdown }),
      });
    
      if (!response.ok) {
        const body = await response.text().catch(() => response.statusText);
        if (response.status === 401 && auth.mode === 'api_key') {
          throw new Error(`Personal API key rejected (HTTP 401). Rotate the key from your plsreadme account page and update ${PLSREADME_API_KEY_ENV}.`);
        }
        if (response.status === 413) throw new Error(`Content too large (max ~200KB). ${body}`);
        if (response.status >= 500) throw new Error(`plsreadme.com unavailable (HTTP ${response.status}). Try again.`);
        throw new Error(`Upload failed (HTTP ${response.status}): ${body}`);
      }
    
      return (await response.json()) as CreateResponse;
    }
    
    async function apiUpdate(id: string, token: string, markdown: string): Promise<void> {
      const response = await fetch(`${PLSREADME_VIEW}/${id}`, {
        method: 'PUT',
        headers: {
          'Content-Type': 'application/json',
          Authorization: `Bearer ${token}`,
        },
        body: JSON.stringify({ markdown }),
      });
    
      if (!response.ok) {
        const body = await response.text().catch(() => response.statusText);
        throw new Error(`Update failed (HTTP ${response.status}): ${body}`);
      }
    }
Behavior1/5

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

The description contradicts the annotation 'readOnlyHint=true' by stating it uploads the file and may update existing links, indicating a write operation. This is a serious inconsistency, so score 1 as per rules.

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?

Four concise sentences, no redundant information. The first sentence captures the primary purpose, and each subsequent sentence adds relevant detail without excess.

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

Completeness4/5

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

For a single-parameter tool with no output schema, the description adequately covers the main behavior: reading, uploading, updating if previously shared, and tracking links. It lacks details on error cases or URL format, but overall sufficient.

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

Parameters3/5

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

Schema coverage is 100% and the parameter 'file_path' is well-described in the schema. The description adds context about reading and uploading the file, but does not significantly add meaning beyond the schema. Baseline 3 applies.

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

Purpose5/5

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

The description clearly states the tool shares a local markdown file as a web link, with specific verb 'Share' and resource 'local markdown file'. It distinguishes from siblings like 'share_text' (which shares raw text) and 'update' (which updates existing links).

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

Usage Guidelines3/5

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

The description implies usage when a markdown file needs sharing, and mentions updating existing links. However, it does not explicitly exclude other use cases or provide guidance on when not to use this tool versus alternatives like 'share_text' or 'update'.

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/FacundoLucci/plsreadme'

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