Skip to content

Commit

Permalink
fix: improve type safety and test coveragenn- Enhanced Notion serv…
Browse files Browse the repository at this point in the history
…ice type definitions and standardization`n- Improved test coverage and configuration`n- Fixed page parent handling and search pagination`n- Removed outdated documentation`n`nThis is a patch release (1.0.1) focusing on type safety improvements and bug fixes.
  • Loading branch information
Ejb503 committed Jan 15, 2025
1 parent 3c4b043 commit 0c436d5
Show file tree
Hide file tree
Showing 13 changed files with 435 additions and 101 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@

All notable changes to this project will be documented in this file.

## [1.0.1] - 2024-03-26

### Changed

- Improved Notion service type definitions and standardization
- Enhanced test coverage and configuration
- Refactored page parent handling for better type safety
- Updated search functionality to include pagination support
- Optimized Jest configuration for better test performance

### Fixed

- Fixed page parent type handling and mapping
- Corrected search results pagination structure
- Removed outdated documentation references

## [1.0.0] - 2024-02-24

### Added
10 changes: 0 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ Before using this server, you'll need:

4. **MCP-Compatible Client**
- [Systemprompt MCP Client](https://github.com/Ejb503/multimodal-mcp-client)
- Claude Desktop
- Any other MCP-compatible client

## Quick Start
Expand Down Expand Up @@ -117,15 +116,6 @@ Before using this server, you'll need:
}
```

4. **Basic Usage**

```typescript
import { NotionMCPServer } from "systemprompt-mcp-notion";

const server = new NotionMCPServer();
server.start();
```

## Development

### Setup
Expand Down
27 changes: 11 additions & 16 deletions jest.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,28 @@ export default {
testEnvironment: "node",
extensionsToTreatAsEsm: [".ts", ".mts"],
moduleNameMapper: {
"^(\\.{1,2}/.*)\\.js$": "$1",
"(.+)\\.js": "$1",
},
transform: {
"^.+\\.tsx?$": [
"^.+\\.ts$": [
"ts-jest",
{
tsconfig: "tsconfig.test.json",
useESM: true,
tsconfig: "tsconfig.json",
diagnostics: {
ignoreCodes: [2571, 6133, 6196, 2322, 2345],
ignoreCodes: [1343],
},
},
],
},
transformIgnorePatterns: [
"/node_modules/(?!(@modelcontextprotocol|@notionhq|zod))",
],
testMatch: ["**/__tests__/**/*.test.ts"],
globals: {
"ts-jest": {
isolatedModules: true,
useESM: true,
},
},
collectCoverage: true,
collectCoverageFrom: [
"src/**/*.{ts,tsx}",
"src/**/*.ts",
"!src/**/*.test.ts",
"!src/**/*.d.ts",
"!src/**/__tests__/**",
"!src/**/__mocks__/**",
"!src/types/**/*",
],
coverageReporters: ["lcov", "text", "text-summary"],
coverageDirectory: "coverage",
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "systemprompt-mcp-notion",
"version": "1.0.0",
"version": "1.0.1",
"description": "A specialized Model Context Protocol (MCP) server that integrates Notion into your AI workflows. This server enables seamless access to Notion through MCP, allowing AI agents to interact with pages, databases, and comments.",
"type": "module",
"bin": {
Expand Down
55 changes: 55 additions & 0 deletions src/config/__tests__/server-config.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { describe, it, expect } from "@jest/globals";
import { serverConfig, serverCapabilities } from "../server-config.js";

describe("Server Configuration", () => {
describe("serverConfig", () => {
it("should have correct basic properties", () => {
expect(serverConfig.name).toBe("systemprompt-mcp-notion");
expect(serverConfig.version).toBe("1.0.0");
});

it("should have correct metadata", () => {
expect(serverConfig.metadata).toBeDefined();
expect(serverConfig.metadata.name).toBe(
"System Prompt Notion Integration Server"
);
expect(serverConfig.metadata.icon).toBe("mdi:notion");
expect(serverConfig.metadata.color).toBe("black");
expect(typeof serverConfig.metadata.serverStartTime).toBe("number");
expect(serverConfig.metadata.environment).toBe(process.env.NODE_ENV);
});

it("should have correct custom data", () => {
expect(serverConfig.metadata.customData).toBeDefined();
expect(serverConfig.metadata.customData.serverFeatures).toEqual([
"notion-pages",
"notion-databases",
"notion-comments",
]);
expect(serverConfig.metadata.customData.supportedAPIs).toEqual([
"notion",
]);
expect(serverConfig.metadata.customData.authProvider).toBe("notion-api");
expect(serverConfig.metadata.customData.requiredCapabilities).toEqual([
"read_content",
"update_content",
"insert_content",
"comment_access",
]);
});
});

describe("serverCapabilities", () => {
it("should have correct capabilities structure", () => {
expect(serverCapabilities.capabilities).toEqual({
resources: {
listChanged: true,
},
tools: {},
prompts: {
listChanged: true,
},
});
});
});
});
17 changes: 16 additions & 1 deletion src/config/server-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,22 @@ import {
ServerCapabilities,
} from "@modelcontextprotocol/sdk/types.js";

export const serverConfig: Implementation = {
interface ServerMetadata {
name: string;
description: string;
icon: string;
color: string;
serverStartTime: number;
environment: string | undefined;
customData: {
serverFeatures: string[];
supportedAPIs: string[];
authProvider: string;
requiredCapabilities: string[];
};
}

export const serverConfig: Implementation & { metadata: ServerMetadata } = {
name: "systemprompt-mcp-notion",
version: "1.0.0",
metadata: {
Expand Down
12 changes: 10 additions & 2 deletions src/handlers/__tests__/tool-handlers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,18 @@ const mockComment = {
const mockNotionService = {
searchPages: jest
.fn<typeof NotionService.prototype.searchPages>()
.mockResolvedValue([mockPage]),
.mockResolvedValue({
pages: [mockPage],
hasMore: false,
nextCursor: undefined,
}),
searchPagesByTitle: jest
.fn<typeof NotionService.prototype.searchPagesByTitle>()
.mockResolvedValue([mockPage]),
.mockResolvedValue({
pages: [mockPage],
hasMore: false,
nextCursor: undefined,
}),
getPage: jest
.fn<typeof NotionService.prototype.getPage>()
.mockResolvedValue(mockPage),
Expand Down
13 changes: 8 additions & 5 deletions src/handlers/tool-handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,18 @@ export async function handleToolCall(
// Page Search and Retrieval
case "systemprompt_search_notion_pages": {
const args = request.params.arguments as unknown as SearchPagesArgs;
const pages = await notion.searchPages(args.query, args.maxResults);
console.log("Search pages result:", pages);
const searchResult = await notion.searchPages(
args.query,
args.maxResults
);
console.log("Search pages result:", searchResult);
return {
content: [
{
type: "resource" as const,
resource: {
uri: "notion://pages",
text: JSON.stringify(pages, null, 2),
text: JSON.stringify(searchResult.pages, null, 2),
mimeType: "application/json",
},
},
Expand All @@ -52,7 +55,7 @@ export async function handleToolCall(
case "systemprompt_search_notion_pages_by_title": {
const args = request.params
.arguments as unknown as SearchPagesByTitleArgs;
const pages = await notion.searchPagesByTitle(
const searchResult = await notion.searchPagesByTitle(
args.title,
args.maxResults
);
Expand All @@ -62,7 +65,7 @@ export async function handleToolCall(
type: "resource" as const,
resource: {
uri: "notion://pages",
text: JSON.stringify(pages, null, 2),
text: JSON.stringify(searchResult.pages, null, 2),
mimeType: "application/json",
},
},
Expand Down
Loading

0 comments on commit 0c436d5

Please sign in to comment.