A comprehensive MCP server for the Hashnode GraphQL API with full TDD coverage
npm install hashnode-mcpSupercharge your AI assistant with complete Hashnode integration




A comprehensive Model Context Protocol server that exposes the complete Hashnode GraphQL API as MCP tools, enabling seamless integration between your Hashnode blog and MCP-compatible applications like Claude Desktop and Cline.
Features โข Installation โข Available Tools โข Configuration โข Development
---
- ๐ 21 Comprehensive Tools - Complete Hashnode API coverage
- ๐ Hot-Swap Architecture - Automatic tool discovery with zero-config
- ๐ฏ Type-Safe - Built with TypeScript strict mode and Zod validation
- ๐ High Test Coverage - 95%+ coverage with TDD methodology
- ๐ Zero Dependencies - Minimal footprint, maximum performance
- ๐ Drop-in Integration - Works with Claude Desktop, Cline, and other MCP clients
- โ๏ธ Full CRUD Operations - Read, write, update, and delete posts and drafts
- ๐
Scheduling Support - Schedule and manage post publication times
This MCP server provides 21 tools covering the full spectrum of Hashnode API operations:
getPublicationByHost | Retrieve publication information by domain |getPublicationPosts | Fetch posts from a publication with pagination |getPostBySlug | Get a specific post by its slug |searchPosts | Search for posts within a publication |getUserByUsername | Retrieve user profile information |getMe | Get current authenticated user information |getMyDrafts | Retrieve drafts for the authenticated user |getMyPosts | Retrieve published posts for the authenticated user |createDraft | Create a new draft for a publication |updateDraft | Update an existing draft |publishDraft | Publish a draft to make it a live post |createPost | Create and publish a post directly |updatePost | Update an existing published post |removePost | Remove/delete a published post |restorePost | Restore a previously removed post |scheduleDraft | Schedule a draft for future publication |rescheduleDraft | Reschedule a previously scheduled draft |cancelScheduledDraft | Cancel a scheduled draft |getSeriesBySlug | Get series information by slug |getSeriesPosts | Retrieve posts from a series with pagination |addPostToSeries | Add a post to an existing series |getStaticPageBySlug | Get a static page by its slug |Add to your Claude Desktop config (~/Library/Application Support/Claude/claude_desktop_config.json on macOS):
``json`
{
"mcpServers": {
"hashnode": {
"command": "npx",
"args": ["-y", "hashnode-mcp"]
}
}
}
`bash`
npm install -g hashnode-mcp
Add to your Cline MCP settings (cline_mcp_settings.json):
`json`
{
"mcpServers": {
"hashnode": {
"command": "npx",
"args": ["-y", "hashnode-mcp"]
}
}
}
Some operations require a Hashnode Personal Access Token (PAT). Get your PAT from Hashnode Settings.
#### With Environment Variable
`bash`
export HASHNODE_API_TOKEN="your-token-here"
#### With Claude Desktop/Cline
Add the token to your MCP configuration:
`json`
{
"mcpServers": {
"hashnode": {
"command": "npx",
"args": ["-y", "hashnode-mcp"],
"env": {
"HASHNODE_API_TOKEN": "your-token-here"
}
}
}
}
Operations requiring authentication:
- โ
Getting authenticated user info (getMe, getMyDrafts, getMyPosts)
- โ
Creating/updating drafts and posts
- โ
Publishing and scheduling
- โ
Series management
- โ
Post removal and restoration
`typescript`
// MCP clients can invoke:
{
"tool": "getPublicationByHost",
"arguments": {
"host": "blog.hashnode.com"
}
}
`typescript`
{
"tool": "searchPosts",
"arguments": {
"publicationId": "your-publication-id",
"query": "GraphQL tutorial",
"first": 10
}
}
`typescript`
{
"tool": "createDraft",
"arguments": {
"publicationId": "your-publication-id",
"title": "My New Post",
"contentMarkdown": "# Hello World\n\nThis is my post content."
}
}
`typescript`
{
"tool": "scheduleDraft",
"arguments": {
"draftId": "your-draft-id",
"authorId": "your-author-id",
"publishAt": "2024-12-31T00:00:00.000Z"
}
}
This server uses a hot-swap autoloader pattern:
``
src/
โโโ index.ts # Entry point with MCP server setup
โโโ server.ts # Server creation and tool registration
โโโ autoloader.ts # Dynamic tool discovery
โโโ utils/
โ โโโ graphql-client.ts # GraphQL client with error handling
โโโ tools/ # Tool implementations
โโโ publication.ts # Each exports toolDefinitions
โโโ post.ts
โโโ user.ts
โโโ me.ts
โโโ draft.ts
โโโ series.ts
โโโ static-page.ts
Key Benefits:
- Add new tools by dropping files in src/tools/
- Zero server code changes required
- Each tool is independently testable
- 95%+ coverage on all tools
Publication Tools
- host (string, required) - The host domain of the publication
- Returns: Publication object with id, title, description, and metadata
- publicationId (string, required) - The ID of the publicationfirst
- (number, optional, default: 10) - Number of posts to fetchafter
- (string, optional) - Cursor for pagination
- Returns: PostConnection with edges, pageInfo for pagination
Post Tools
- publicationHost (string, required) - The host domain of the publicationslug
- (string, required) - The slug of the post
- Returns: Post object with id, title, slug, brief, url, and content
- publicationId (string, required) - The ID of the publicationquery
- (string, required) - Search query stringfirst
- (number, optional, default: 10) - Number of results to fetch
- Returns: SearchPostConnection with matching posts
User Tools
- username (string, required) - The username of the user
- Returns: User object with id, username, name, tagline, and bio
- Returns: User object with id, username, name, tagline, and bio
- first (number, optional, default: 10) - Number of drafts to fetch
- Returns: DraftConnection with edges and pageInfo for pagination
- first (number, optional, default: 10) - Number of posts to fetch
- Returns: PostConnection with edges and pageInfo for pagination
Draft & Publishing Tools
All tools in this section require authentication via HASHNODE_API_TOKEN.
- publicationId (string, required) - The ID of the publicationtitle
- (string, required) - The title of the draftcontentMarkdown
- (string, required) - The content in Markdown format
- Returns: Draft object with id, title, and slug
- draftId (string, required) - The ID of the draft to updatetitle
- (string, required) - The updated titlecontentMarkdown
- (string, required) - The updated content in Markdown
- Returns: Updated Draft object
- draftId (string, required) - The ID of the draft to publish
- Returns: Published Post object with id, title, slug, and url
- publicationId (string, required) - The ID of the publicationtitle
- (string, required) - The title of the postcontentMarkdown
- (string, required) - The content in Markdown format
- Returns: Published Post object with id, title, slug, and url
- postId (string, required) - The ID of the post to updatetitle
- (string, required) - The updated titlecontentMarkdown
- (string, required) - The updated content in Markdown
- Returns: Updated Post object with id, title, slug, and url
- postId (string, required) - The ID of the post to remove
- Returns: Removed Post object with id, title, slug, and url
- postId (string, required) - The ID of the post to restore
- Returns: Restored Post object with id, title, slug, and url
Scheduling Tools
All tools in this section require authentication via HASHNODE_API_TOKEN.
- draftId (string, required) - The ID of the draft to scheduleauthorId
- (string, required) - The ID of the author scheduling the draftpublishAt
- (string, required) - ISO 8601 date-time string (e.g., "2024-12-31T00:00:00.000Z")
- Returns: ScheduledPost object with id and scheduledDate
- draftId (string, required) - The ID of the scheduled draftpublishAt
- (string, required) - New ISO 8601 date-time string for publication
- Returns: ScheduledPost object with id and updated scheduledDate
- draftId (string, required) - The ID of the scheduled draft to cancel
- Returns: ScheduledPost object with id and scheduledDate
Series Tools
- publicationHost (string, required) - The host domain of the publicationslug
- (string, required) - The slug of the series
- Returns: Series object with id, name, slug, and description
- publicationHost (string, required) - The host domain of the publicationseriesSlug
- (string, required) - The slug of the seriesfirst
- (number, optional, default: 10) - Number of posts to fetch
- Returns: SeriesPostConnection with edges and pageInfo
- seriesId (string, required) - The ID of the seriespostId
- (string, required) - The ID of the post to add
- Returns: Series object with id, name, and slug
Static Page Tools
- publicationHost (string, required) - The host domain of the publicationslug
- (string, required) - The slug of the static page
- Returns: StaticPage object with id, title, slug, and content
- Node.js v16+
- npm or pnpm
`bashClone repository
git clone https://github.com/rawveg/hashnode-mcp.git
cd hashnode-mcp
$3
This project follows a strict TDD methodology:
`
Statements : 95%+
Branches : 95%+
Functions : 100%
Lines : 95%+
`Testing Philosophy:
- Red-Green-Refactor cycle for all features
- Critical paths always tested
- Edge cases selectively tested
- Error paths prioritized by impact
$3
1. Create
src/tools/your-tool.ts:`typescript
import { ToolDefinition } from '../autoloader.js';
import { GraphQLClient } from '../utils/graphql-client.js';export const toolDefinitions: ToolDefinition[] = [
{
name: 'yourTool',
description: 'Your tool description',
inputSchema: {
type: 'object',
properties: {
param: { type: 'string' }
},
required: ['param']
},
handler: async (client, args) => {
// Implementation
return 'result';
}
}
];
`2. Create tests in
__tests__/tools/your-tool.test.ts
3. Done! The autoloader discovers it automatically.๐ค Contributing
Contributions are welcome! Please follow these guidelines:
1. Fork the repository
2. Create a feature branch (
git checkout -b feature/amazing-feature)
3. Write tests - We maintain 95%+ coverage
4. Commit with clear messages (git commit -m 'Add amazing feature')
5. Push to your branch (git push origin feature/amazing-feature)
6. Open a Pull Request$3
- All new tools must export
toolDefinitions`This project is licensed under the GNU Affero General Public License v3.0 (AGPL-3.0).
See LICENSE for details.
- Hashnode API Documentation - Official Hashnode GraphQL API docs
- Model Context Protocol - Open standard for AI assistant integration
- Claude Desktop - Anthropic's desktop application
- Cline - VS Code AI assistant
Built with:
- MCP SDK - Model Context Protocol SDK
- Hashnode GraphQL API - Hashnode's official API
---
Made with โค๏ธ by Tim Green