search1api-mcp 0.3.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,22 +2,33 @@ import { isValidNewsArgs } from '../types.js';
2
2
  import { makeRequest } from '../api.js';
3
3
  import { formatError, log } from '../utils.js';
4
4
  import { API_CONFIG } from '../config.js';
5
- import { McpError, ErrorCode } from "@modelcontextprotocol/sdk/types.js";
5
+ import { INVALID_PARAMS, ProtocolError, } from "@modelcontextprotocol/server";
6
6
  /**
7
7
  * Implementation of the news search tool
8
8
  */
9
9
  export async function handleNews(args, apiKey) {
10
10
  if (!isValidNewsArgs(args)) {
11
- throw new McpError(ErrorCode.InvalidParams, "Invalid news search arguments");
11
+ throw new ProtocolError(INVALID_PARAMS, "Invalid news search arguments");
12
12
  }
13
13
  log("Processing news search with query:", args.query);
14
14
  try {
15
15
  const response = await makeRequest(API_CONFIG.ENDPOINTS.NEWS, args, apiKey);
16
+ const results = response.results.map((result) => ({
17
+ id: result.link,
18
+ title: result.title,
19
+ url: result.link,
20
+ text: result.content || result.snippet,
21
+ metadata: {
22
+ snippet: result.snippet,
23
+ ...(result.content ? { has_full_content: true } : {}),
24
+ },
25
+ }));
26
+ const structuredContent = { results };
16
27
  return {
28
+ structuredContent,
17
29
  content: [{
18
30
  type: "text",
19
- mimeType: "application/json",
20
- text: JSON.stringify(response.results, null, 2)
31
+ text: JSON.stringify(structuredContent)
21
32
  }]
22
33
  };
23
34
  }
@@ -26,7 +37,6 @@ export async function handleNews(args, apiKey) {
26
37
  return {
27
38
  content: [{
28
39
  type: "text",
29
- mimeType: "text/plain",
30
40
  text: `News API error: ${formatError(error)}`
31
41
  }],
32
42
  isError: true
@@ -2,21 +2,32 @@ import { isValidSearchArgs } from '../types.js';
2
2
  import { makeRequest } from '../api.js';
3
3
  import { formatError } from '../utils.js';
4
4
  import { API_CONFIG } from '../config.js';
5
- import { McpError, ErrorCode } from "@modelcontextprotocol/sdk/types.js";
5
+ import { INVALID_PARAMS, ProtocolError, } from "@modelcontextprotocol/server";
6
6
  /**
7
7
  * Implementation of the search tool
8
8
  */
9
9
  export async function handleSearch(args, apiKey) {
10
10
  if (!isValidSearchArgs(args)) {
11
- throw new McpError(ErrorCode.InvalidParams, "Invalid search arguments");
11
+ throw new ProtocolError(INVALID_PARAMS, "Invalid search arguments");
12
12
  }
13
13
  try {
14
14
  const response = await makeRequest(API_CONFIG.ENDPOINTS.SEARCH, args, apiKey);
15
+ const results = response.results.map((result) => ({
16
+ id: result.link,
17
+ title: result.title,
18
+ url: result.link,
19
+ text: result.content || result.snippet,
20
+ metadata: {
21
+ snippet: result.snippet,
22
+ ...(result.content ? { has_full_content: true } : {}),
23
+ },
24
+ }));
25
+ const structuredContent = { results };
15
26
  return {
27
+ structuredContent,
16
28
  content: [{
17
29
  type: "text",
18
- mimeType: "application/json",
19
- text: JSON.stringify(response.results, null, 2)
30
+ text: JSON.stringify(structuredContent)
20
31
  }]
21
32
  };
22
33
  }
@@ -24,7 +35,6 @@ export async function handleSearch(args, apiKey) {
24
35
  return {
25
36
  content: [{
26
37
  type: "text",
27
- mimeType: "text/plain",
28
38
  text: `Search API error: ${formatError(error)}`
29
39
  }],
30
40
  isError: true
@@ -2,21 +2,22 @@ import { isValidSitemapArgs } from '../types.js';
2
2
  import { makeRequest } from '../api.js';
3
3
  import { formatError } from '../utils.js';
4
4
  import { API_CONFIG } from '../config.js';
5
- import { McpError, ErrorCode } from "@modelcontextprotocol/sdk/types.js";
5
+ import { INVALID_PARAMS, ProtocolError, } from "@modelcontextprotocol/server";
6
6
  /**
7
7
  * Implementation of the sitemap tool
8
8
  */
9
9
  export async function handleSitemap(args, apiKey) {
10
10
  if (!isValidSitemapArgs(args)) {
11
- throw new McpError(ErrorCode.InvalidParams, "Invalid sitemap arguments");
11
+ throw new ProtocolError(INVALID_PARAMS, "Invalid sitemap arguments");
12
12
  }
13
13
  try {
14
14
  const response = await makeRequest(API_CONFIG.ENDPOINTS.SITEMAP, args, apiKey);
15
+ const structuredContent = { links: response.links };
15
16
  return {
17
+ structuredContent,
16
18
  content: [{
17
19
  type: "text",
18
- mimeType: "application/json",
19
- text: JSON.stringify(response.links, null, 2)
20
+ text: JSON.stringify(structuredContent)
20
21
  }]
21
22
  };
22
23
  }
@@ -24,7 +25,6 @@ export async function handleSitemap(args, apiKey) {
24
25
  return {
25
26
  content: [{
26
27
  type: "text",
27
- mimeType: "text/plain",
28
28
  text: `Sitemap API error: ${formatError(error)}`
29
29
  }],
30
30
  isError: true
@@ -2,21 +2,22 @@ import { isValidTrendingArgs } from '../types.js';
2
2
  import { makeRequest } from '../api.js';
3
3
  import { formatError } from '../utils.js';
4
4
  import { API_CONFIG } from '../config.js';
5
- import { McpError, ErrorCode } from "@modelcontextprotocol/sdk/types.js";
5
+ import { INVALID_PARAMS, ProtocolError, } from "@modelcontextprotocol/server";
6
6
  /**
7
7
  * Implementation of the trending tool
8
8
  */
9
9
  export async function handleTrending(args, apiKey) {
10
10
  if (!isValidTrendingArgs(args)) {
11
- throw new McpError(ErrorCode.InvalidParams, "Invalid trending arguments");
11
+ throw new ProtocolError(INVALID_PARAMS, "Invalid trending arguments");
12
12
  }
13
13
  try {
14
14
  const response = await makeRequest(API_CONFIG.ENDPOINTS.TRENDING, args, apiKey);
15
+ const structuredContent = { results: response.results };
15
16
  return {
17
+ structuredContent,
16
18
  content: [{
17
19
  type: "text",
18
- mimeType: "application/json",
19
- text: JSON.stringify(response.results, null, 2)
20
+ text: JSON.stringify(structuredContent)
20
21
  }]
21
22
  };
22
23
  }
@@ -24,7 +25,6 @@ export async function handleTrending(args, apiKey) {
24
25
  return {
25
26
  content: [{
26
27
  type: "text",
27
- mimeType: "text/plain",
28
28
  text: `Trending API error: ${formatError(error)}`
29
29
  }],
30
30
  isError: true
package/build/types.js CHANGED
@@ -62,6 +62,13 @@ export function isValidSearchArgs(args) {
62
62
  }
63
63
  return true;
64
64
  }
65
+ export function isValidFetchArgs(args) {
66
+ if (typeof args !== "object" || args === null) {
67
+ return false;
68
+ }
69
+ const { id } = args;
70
+ return typeof id === "string" && id.trim().length > 0;
71
+ }
65
72
  export function isValidCrawlArgs(args) {
66
73
  if (typeof args !== 'object' || args === null) {
67
74
  return false;
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "search1api-mcp",
3
- "version": "0.3.1",
3
+ "version": "0.5.0",
4
+ "mcpName": "io.github.superagents-lab/search1api",
4
5
  "description": "A Model Context Protocol (MCP) server that provides search and crawl functionality using Search1API",
5
6
  "private": false,
6
7
  "type": "module",
@@ -8,7 +9,8 @@
8
9
  "search1api-mcp": "build/index.js"
9
10
  },
10
11
  "files": [
11
- "build"
12
+ "build",
13
+ "server.json"
12
14
  ],
13
15
  "scripts": {
14
16
  "build": "node -e \"require('node:fs').rmSync('build', { recursive: true, force: true })\" && tsc && node -e \"require('node:fs').chmodSync('build/index.js', '755')\"",
@@ -17,14 +19,17 @@
17
19
  "prepack": "npm run build",
18
20
  "watch": "tsc --watch",
19
21
  "inspector": "npx @modelcontextprotocol/inspector build/index.js",
20
- "start:http": "node build/http.js"
22
+ "start:http": "node build/http.js",
23
+ "sync:manifest": "npm run build && node scripts/sync-lobe-manifest.mjs"
21
24
  },
22
25
  "dependencies": {
23
- "@modelcontextprotocol/sdk": "^1.29.0",
26
+ "@modelcontextprotocol/node": "^2.0.0",
27
+ "@modelcontextprotocol/server": "^2.0.0",
24
28
  "dotenv": "^16.6.1",
25
29
  "express": "^4.22.2"
26
30
  },
27
31
  "devDependencies": {
32
+ "@modelcontextprotocol/client": "^2.0.0",
28
33
  "@types/express": "^5.0.6",
29
34
  "@types/node": "^20.19.43",
30
35
  "typescript": "^5.9.3"
@@ -51,6 +56,6 @@
51
56
  "access": "public"
52
57
  },
53
58
  "engines": {
54
- "node": ">=18.0.0"
59
+ "node": ">=20.0.0"
55
60
  }
56
61
  }
package/server.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
3
+ "name": "io.github.superagents-lab/search1api",
4
+ "title": "Search1API",
5
+ "description": "Web search, news, page retrieval, sitemaps, and trending topics through Search1API.",
6
+ "repository": {
7
+ "url": "https://github.com/superagents-lab/search1api-mcp",
8
+ "source": "github"
9
+ },
10
+ "version": "0.5.0",
11
+ "remotes": [
12
+ {
13
+ "type": "streamable-http",
14
+ "url": "https://mcp.search1api.com/mcp"
15
+ }
16
+ ],
17
+ "packages": [
18
+ {
19
+ "registryType": "npm",
20
+ "identifier": "search1api-mcp",
21
+ "version": "0.5.0",
22
+ "transport": {
23
+ "type": "stdio"
24
+ },
25
+ "environmentVariables": [
26
+ {
27
+ "name": "SEARCH1API_KEY",
28
+ "description": "Search1API API key for local stdio mode",
29
+ "isRequired": true,
30
+ "isSecret": true,
31
+ "format": "string"
32
+ }
33
+ ]
34
+ }
35
+ ]
36
+ }