Skip to main content
Glama
prismism-dev

Prismism MCP Server

by prismism-dev

prismism_publish

Upload files to generate shareable, tracked links for PDFs, HTML, Markdown, images, and videos. Send content as plain text or base64-encoded for binary files.

Instructions

Upload a file and get a shareable, tracked link. Supports PDF, HTML, Markdown, images (PNG/JPG/GIF/SVG/WebP), and video (MP4). Send content as plain text (default) or base64 for binary files.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentYesFile content — plain text (default) or base64-encoded for binary files
filenameYesFilename with extension, e.g. "report.pdf" or "chart.png"
encodingNoContent encoding — use "base64" for binary files like PDFs, images, or videoutf8
contentTypeNoMIME type — auto-detected from filename if not provided
titleNoDisplay title for the artifact

Implementation Reference

  • The handler function for the 'prismism_publish' tool, which manages file uploading, content type resolution, and optional title updates for artifacts.
    async ({ content, filename, encoding, contentType, title }) => {
      if (!hasApiKey()) {
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify({
                ok: false,
                error: { code: 'NO_API_KEY', message: 'API key required to publish' },
                _hints: ['Set PRISMISM_API_KEY in your MCP config. Use prismism_register to create an account.'],
              }),
            },
          ],
          isError: true,
        };
      }
    
      // Convert content to Buffer
      const buffer = encoding === 'base64' ? Buffer.from(content, 'base64') : Buffer.from(content, 'utf-8');
    
      const resolvedContentType = contentType || inferContentType(filename);
    
      const result = await upload<{
        id: string;
        shortId: string;
        title: string;
        url: string;
        filename: string;
        mimeType: string;
        size: number;
        allowDownload: boolean;
        createdAt: string;
      }>('/v1/artifacts', buffer, filename, resolvedContentType);
    
      if (!result.ok) {
        return {
          content: [{ type: 'text', text: JSON.stringify(result) }],
          isError: true,
        };
      }
    
      // If a title was provided, update the artifact
      if (title && result.data?.id) {
        await patch(`/v1/artifacts/${result.data.id}`, { title });
        if (result.data) {
          result.data.title = title;
        }
      }
    
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify({
              ok: true,
              data: result.data,
              _hints: result.data?.url ? [`Shareable link: ${result.data.url}`] : undefined,
            }),
          },
        ],
      };
    }
  • The input schema defining the parameters for the 'prismism_publish' tool.
    inputSchema: {
      content: z.string().describe('File content — plain text (default) or base64-encoded for binary files'),
      filename: z.string().describe('Filename with extension, e.g. "report.pdf" or "chart.png"'),
      encoding: z.enum(['utf8', 'base64']).default('utf8').describe('Content encoding — use "base64" for binary files like PDFs, images, or video'),
      contentType: z.string().optional().describe('MIME type — auto-detected from filename if not provided'),
      title: z.string().optional().describe('Display title for the artifact'),
    },
  • The registration function that defines the 'prismism_publish' tool on the MCP server instance.
    export function registerPublishTool(server: McpServer) {
      server.registerTool(
        'prismism_publish',
        {
          title: 'Publish File to Prismism',
          description:
            'Upload a file and get a shareable, tracked link. Supports PDF, HTML, Markdown, images (PNG/JPG/GIF/SVG/WebP), and video (MP4). Send content as plain text (default) or base64 for binary files.',
          inputSchema: {
            content: z.string().describe('File content — plain text (default) or base64-encoded for binary files'),
            filename: z.string().describe('Filename with extension, e.g. "report.pdf" or "chart.png"'),
            encoding: z.enum(['utf8', 'base64']).default('utf8').describe('Content encoding — use "base64" for binary files like PDFs, images, or video'),
            contentType: z.string().optional().describe('MIME type — auto-detected from filename if not provided'),
            title: z.string().optional().describe('Display title for the artifact'),
          },
        },
        async ({ content, filename, encoding, contentType, title }) => {
          if (!hasApiKey()) {
            return {
              content: [
                {
                  type: 'text',
                  text: JSON.stringify({
                    ok: false,
                    error: { code: 'NO_API_KEY', message: 'API key required to publish' },
                    _hints: ['Set PRISMISM_API_KEY in your MCP config. Use prismism_register to create an account.'],
                  }),
                },
              ],
              isError: true,
            };
          }
    
          // Convert content to Buffer
          const buffer = encoding === 'base64' ? Buffer.from(content, 'base64') : Buffer.from(content, 'utf-8');
    
          const resolvedContentType = contentType || inferContentType(filename);
    
          const result = await upload<{
            id: string;
            shortId: string;
            title: string;
            url: string;
            filename: string;
            mimeType: string;
            size: number;
            allowDownload: boolean;
            createdAt: string;
          }>('/v1/artifacts', buffer, filename, resolvedContentType);
    
          if (!result.ok) {
            return {
              content: [{ type: 'text', text: JSON.stringify(result) }],
              isError: true,
            };
          }
    
          // If a title was provided, update the artifact
          if (title && result.data?.id) {
            await patch(`/v1/artifacts/${result.data.id}`, { title });
            if (result.data) {
              result.data.title = title;
            }
          }
    
          return {
            content: [
              {
                type: 'text',
                text: JSON.stringify({
                  ok: true,
                  data: result.data,
                  _hints: result.data?.url ? [`Shareable link: ${result.data.url}`] : undefined,
                }),
              },
            ],
          };
        }
      );
    }

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/prismism-dev/mcp-server'

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