@mastra/mcp-docs-server 1.1.32-alpha.2 → 1.1.32-alpha.3
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.
- package/.docs/reference/index.md +1 -0
- package/.docs/reference/tools/perplexity.md +155 -0
- package/CHANGELOG.md +7 -0
- package/package.json +4 -4
package/.docs/reference/index.md
CHANGED
|
@@ -224,6 +224,7 @@ The Reference section provides documentation of Mastra's API, including paramete
|
|
|
224
224
|
- [createVectorQueryTool()](https://mastra.ai/reference/tools/vector-query-tool)
|
|
225
225
|
- [MCPClient](https://mastra.ai/reference/tools/mcp-client)
|
|
226
226
|
- [MCPServer](https://mastra.ai/reference/tools/mcp-server)
|
|
227
|
+
- [Perplexity Tools](https://mastra.ai/reference/tools/perplexity)
|
|
227
228
|
- [Tavily Tools](https://mastra.ai/reference/tools/tavily)
|
|
228
229
|
- [Amazon S3 Vector Store](https://mastra.ai/reference/vectors/s3vectors)
|
|
229
230
|
- [Astra Vector Store](https://mastra.ai/reference/vectors/astra)
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
# Perplexity tools
|
|
2
|
+
|
|
3
|
+
Added in: `@mastra/perplexity@0.1.0-alpha.0`
|
|
4
|
+
|
|
5
|
+
The `@mastra/perplexity` package wraps the [Perplexity Search API](https://docs.perplexity.ai/docs/search/quickstart) as a Mastra-compatible tool. It exposes a factory function that returns a tool created with [`createTool()`](https://mastra.ai/reference/tools/create-tool) and full Zod input/output schemas.
|
|
6
|
+
|
|
7
|
+
For chat completions or agentic workflows powered by Perplexity, use Mastra's built-in [Perplexity model provider](https://mastra.ai/models/providers/perplexity) or [Perplexity Agent provider](https://mastra.ai/models/providers/perplexity-agent). Those are separate from this Search tool.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
Install the package alongside Zod:
|
|
12
|
+
|
|
13
|
+
**npm**:
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
npm install @mastra/perplexity zod
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
**pnpm**:
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
pnpm add @mastra/perplexity zod
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
**Yarn**:
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
yarn add @mastra/perplexity zod
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
**Bun**:
|
|
32
|
+
|
|
33
|
+
```sh
|
|
34
|
+
bun add @mastra/perplexity zod
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Usage example
|
|
38
|
+
|
|
39
|
+
The following example creates the search tool with the default configuration. By default, the tool reads `PERPLEXITY_API_KEY` (with `PPLX_API_KEY` as a fallback) from the environment. Pass `{ apiKey }` explicitly to override.
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
import { createPerplexitySearchTool } from '@mastra/perplexity'
|
|
43
|
+
|
|
44
|
+
const searchTool = createPerplexitySearchTool()
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
To pass an API key explicitly:
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
import { createPerplexitySearchTool } from '@mastra/perplexity'
|
|
51
|
+
|
|
52
|
+
const searchTool = createPerplexitySearchTool({ apiKey: 'pplx-...' })
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Configuration
|
|
56
|
+
|
|
57
|
+
All factory functions accept a `PerplexityClientOptions` object:
|
|
58
|
+
|
|
59
|
+
**apiKey** (`string`): Perplexity API key. Falls back to the \`PERPLEXITY\_API\_KEY\` then \`PPLX\_API\_KEY\` environment variables.
|
|
60
|
+
|
|
61
|
+
**baseUrl** (`string`): Override the API base URL. (Default: `'https://api.perplexity.ai'`)
|
|
62
|
+
|
|
63
|
+
**fetch** (`typeof fetch`): Custom \`fetch\` implementation. Useful for tests, retries, or instrumentation.
|
|
64
|
+
|
|
65
|
+
## Methods
|
|
66
|
+
|
|
67
|
+
### Factory functions
|
|
68
|
+
|
|
69
|
+
#### `createPerplexityTools(config?)`
|
|
70
|
+
|
|
71
|
+
Returns an object containing all Perplexity tools that share the supplied configuration.
|
|
72
|
+
|
|
73
|
+
```typescript
|
|
74
|
+
import { createPerplexityTools } from '@mastra/perplexity'
|
|
75
|
+
|
|
76
|
+
const tools = createPerplexityTools({ apiKey: 'pplx-...' })
|
|
77
|
+
// tools.perplexitySearch
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Returns: `{ perplexitySearch }`
|
|
81
|
+
|
|
82
|
+
#### `createPerplexitySearchTool(config?)`
|
|
83
|
+
|
|
84
|
+
Creates a tool that searches the web using the Perplexity Search API. Returns ranked results with titles, URLs, snippets, and optional publication dates.
|
|
85
|
+
|
|
86
|
+
The tool is registered with the ID `perplexity-search`.
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
import { createPerplexitySearchTool } from '@mastra/perplexity'
|
|
90
|
+
|
|
91
|
+
const searchTool = createPerplexitySearchTool()
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
##### Input
|
|
95
|
+
|
|
96
|
+
**query** (`string`): The search query.
|
|
97
|
+
|
|
98
|
+
**maxResults** (`number`): Maximum number of results to return (1-20).
|
|
99
|
+
|
|
100
|
+
**searchDomainFilter** (`string[]`): Restrict (or exclude) results by domain. Prefix a domain with \`-\` to exclude it (for example, \`-pinterest.com\`). Do not mix allow- and deny-list entries in the same call.
|
|
101
|
+
|
|
102
|
+
**searchRecencyFilter** (`'hour' | 'day' | 'week' | 'month' | 'year'`): Only return results from within the given recency window.
|
|
103
|
+
|
|
104
|
+
**searchAfterDateFilter** (`string`): Only return results published on or after this date. Format: m/d/yyyy.
|
|
105
|
+
|
|
106
|
+
**searchBeforeDateFilter** (`string`): Only return results published on or before this date. Format: m/d/yyyy.
|
|
107
|
+
|
|
108
|
+
##### Output
|
|
109
|
+
|
|
110
|
+
**query** (`string`): The original search query.
|
|
111
|
+
|
|
112
|
+
**results** (`SearchResult[]`): Array of search results.
|
|
113
|
+
|
|
114
|
+
**results.title** (`string`): Result title.
|
|
115
|
+
|
|
116
|
+
**results.url** (`string`): Result URL.
|
|
117
|
+
|
|
118
|
+
**results.snippet** (`string`): Content snippet.
|
|
119
|
+
|
|
120
|
+
**results.date** (`string`): Publication date when available.
|
|
121
|
+
|
|
122
|
+
## Agent example
|
|
123
|
+
|
|
124
|
+
The following example registers the search tool on an agent so it can fetch fresh web results before answering.
|
|
125
|
+
|
|
126
|
+
```typescript
|
|
127
|
+
import { Agent } from '@mastra/core/agent'
|
|
128
|
+
import { createPerplexitySearchTool } from '@mastra/perplexity'
|
|
129
|
+
|
|
130
|
+
const agent = new Agent({
|
|
131
|
+
id: 'research-agent',
|
|
132
|
+
name: 'Research Agent',
|
|
133
|
+
model: 'anthropic/claude-sonnet-4-6',
|
|
134
|
+
instructions:
|
|
135
|
+
'You are a research assistant. Use the perplexity-search tool to find up-to-date information from the web before answering.',
|
|
136
|
+
tools: {
|
|
137
|
+
search: createPerplexitySearchTool(),
|
|
138
|
+
},
|
|
139
|
+
})
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Environment variables
|
|
143
|
+
|
|
144
|
+
| Variable | Description |
|
|
145
|
+
| -------------------- | ----------------------------------------------------------------------------------------------- |
|
|
146
|
+
| `PERPLEXITY_API_KEY` | Your Perplexity API key. Used as the default when `apiKey` is not passed to a factory function. |
|
|
147
|
+
| `PPLX_API_KEY` | Fallback used when `PERPLEXITY_API_KEY` is unset. |
|
|
148
|
+
|
|
149
|
+
## Related
|
|
150
|
+
|
|
151
|
+
- [`createTool()`](https://mastra.ai/reference/tools/create-tool)
|
|
152
|
+
- [Perplexity Search quickstart](https://docs.perplexity.ai/docs/search/quickstart)
|
|
153
|
+
- [Perplexity Agent quickstart](https://docs.perplexity.ai/docs/agent/quickstart)
|
|
154
|
+
- [Perplexity model provider](https://mastra.ai/models/providers/perplexity)
|
|
155
|
+
- [Perplexity Agent provider](https://mastra.ai/models/providers/perplexity-agent)
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @mastra/mcp-docs-server
|
|
2
2
|
|
|
3
|
+
## 1.1.32-alpha.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`2b0f355`](https://github.com/mastra-ai/mastra/commit/2b0f3553be3e9e5524da539a66e5cf82668440a4)]:
|
|
8
|
+
- @mastra/core@1.31.0-alpha.2
|
|
9
|
+
|
|
3
10
|
## 1.1.32-alpha.2
|
|
4
11
|
|
|
5
12
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/mcp-docs-server",
|
|
3
|
-
"version": "1.1.32-alpha.
|
|
3
|
+
"version": "1.1.32-alpha.3",
|
|
4
4
|
"description": "MCP server for accessing Mastra.ai documentation, changelogs, and news.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"jsdom": "^26.1.0",
|
|
30
30
|
"local-pkg": "^1.1.2",
|
|
31
31
|
"zod": "^4.3.6",
|
|
32
|
-
"@mastra/
|
|
33
|
-
"@mastra/
|
|
32
|
+
"@mastra/mcp": "^1.6.0",
|
|
33
|
+
"@mastra/core": "1.31.0-alpha.2"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@hono/node-server": "^1.19.11",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"vitest": "4.1.5",
|
|
49
49
|
"@internal/lint": "0.0.89",
|
|
50
50
|
"@internal/types-builder": "0.0.64",
|
|
51
|
-
"@mastra/core": "1.31.0-alpha.
|
|
51
|
+
"@mastra/core": "1.31.0-alpha.2"
|
|
52
52
|
},
|
|
53
53
|
"homepage": "https://mastra.ai",
|
|
54
54
|
"repository": {
|