PageIndex MCP SDK - Document processing tools for AI agents via Model Context Protocol
npm install @pageindex/mcp-sdkTypeScript SDK for PageIndex document processing via MCP. Built for AI Agent applications.
- Programmatic access to PageIndex in TypeScript/JavaScript
- Wrapping as tools for AI frameworks without Remote MCP Server support
> For environments with Remote MCP Server support (Claude Desktop, Cursor), use Direct Connection instead.
``bash`
pnpm add @pageindex/mcp-sdk
Requires Node.js >= 18.0.0
`typescript
import { PageIndexClient } from '@pageindex/mcp-sdk';
const client = new PageIndexClient({
apiUrl: 'https://chat.pageindex.ai',
apiKey: 'your-api-key',
});
await client.connect();
const docs = await client.tools.recentDocuments();
await client.close();
`
`typescript
const client = new PageIndexClient({ apiUrl, apiKey, folderScope? });
await client.connect();
await client.setFolderScope(folderId);
`
All methods via client.tools:
| Method | Description |
|--------|-------------|
| processDocument({ url }) | Upload and process document from URL |uploadDocument({ fileName, fileType, fileContent })
| | Upload file and process |recentDocuments()
| | List recent uploads |findRelevantDocuments({ nameOrDescriptionFilter?, limit? })
| | Search documents |getDocument({ docName, waitForCompletion? })
| | Get document details |getDocumentStructure({ docName, part?, waitForCompletion? })
| | Extract document outline |getPageContent({ docName, pages, waitForCompletion? })
| | Extract page content |removeDocument({ docNames })
| | Delete documents |createFolder({ name, description?, parentFolderId? })
| | Create folder |listFolders({ parentFolderId? })
| | List folders |
Page specification formats: "5", "3,7,10", "5-10", "1-3,7,9-12"
`typescript
import { PageIndexError } from '@pageindex/mcp-sdk';
try {
await client.tools.getDocument({ docName: 'xxx' });
} catch (e) {
if (e instanceof PageIndexError) {
// e.code: 'NOT_FOUND' | 'USAGE_LIMIT_REACHED' | 'INVALID_INPUT' | 'INTERNAL_ERROR'
}
}
``
See examples/chat-demo for Next.js + AI SDK integration.
MIT