diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml index a6ba2a3d..e9b6ebe8 100644 --- a/.github/workflows/publish-npm.yml +++ b/.github/workflows/publish-npm.yml @@ -4,10 +4,6 @@ name: Publish NPM on: workflow_dispatch: - inputs: - path: - description: The path to run the release in, e.g. '.' or 'packages/mcp-server' - required: true release: types: [published] @@ -31,11 +27,6 @@ jobs: - name: Publish to NPM run: | - if [ -n "${{ github.event.inputs.path }}" ]; then - PATHS_RELEASED='[\"${{ github.event.inputs.path }}\"]' - else - PATHS_RELEASED='[\".\", \"packages/mcp-server\"]' - fi - yarn tsn scripts/publish-packages.ts "{ \"paths_released\": \"$PATHS_RELEASED\" }" + bash ./bin/publish-npm env: NPM_TOKEN: ${{ secrets.WRITER_NPM_TOKEN || secrets.NPM_TOKEN }} diff --git a/.stats.yml b/.stats.yml index cda70cf6..12896beb 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 30 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/writerai%2Fwriter-d15316b8a3a086ae9ec8eea0d436b0885262df9bcf23b9587ad059e50357c220.yml openapi_spec_hash: 4f81a4f4840438f80eff345e76ead962 -config_hash: 8b4e4a902369723a665b1d265169a3f1 +config_hash: ee2e5a914fd298a6f4c740f5ce187f87 diff --git a/eslint.config.mjs b/eslint.config.mjs index 95b4ce40..7f7c7265 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -34,7 +34,7 @@ export default tseslint.config( }, }, { - files: ['tests/**', 'examples/**', 'packages/**'], + files: ['tests/**', 'examples/**'], rules: { 'no-restricted-imports': 'off', }, diff --git a/packages/mcp-server/README.md b/packages/mcp-server/README.md deleted file mode 100644 index c873d68f..00000000 --- a/packages/mcp-server/README.md +++ /dev/null @@ -1,155 +0,0 @@ -# Writer TypeScript MCP Server - -It is generated with [Stainless](https://www.stainless.com/). - -## Installation - -### Direct invocation - -You can run the MCP Server directly via `npx`: - -```sh -export WRITER_API_KEY = "My API Key" -npx -y writer-sdk-mcp -``` - -### Via MCP Client - -There is a partial list of existing clients at [modelcontextprotocol.io](https://modelcontextprotocol.io/clients). If you already -have a client, consult their documentation to install the MCP server. - -For clients with a configuration JSON, it might look something like this: - -```json -{ - "mcpServers": { - "writer_sdk_api": { - "command": "npx", - "args": ["-y", "writer-sdk-mcp"], - "env": { - "WRITER_API_KEY": "My API Key" - } - } - } -} -``` - -## Filtering tools - -You can run the package on the command line to discover and filter the set of tools that are exposed by the -MCP Server. This can be helpful for large APIs where including all endpoints at once is too much for your AI's -context window. - -You can filter by multiple aspects: - -- `--tool` includes a specific tool by name -- `--resource` includes all tools under a specific resource, and can have wildcards, e.g. `my.resource*` -- `--operation` includes just read (get/list) or just write operations - -See more information with `--help`. - -All of these command-line options can be repeated, combined together, and have corresponding exclusion versions (e.g. `--no-tool`). - -Use `--list` to see the list of available tools, or see below. - -## Importing the tools and server individually - -```js -// Import the server, generated endpoints, or the init function -import { server, endpoints, init } from "writer-sdk-mcp/server"; - -// import a specific tool -import retrieveApplications from "writer-sdk-mcp/tools/applications/retrieve-applications"; - -// initialize the server and all endpoints -init({ server, endpoints }); - -// manually start server -const transport = new StdioServerTransport(); -await server.connect(transport); - -// or initialize your own server with specific tools -const myServer = new McpServer(...); - -// define your own endpoint -const myCustomEndpoint = { - tool: { - name: 'my_custom_tool', - description: 'My custom tool', - inputSchema: zodToJsonSchema(z.object({ a_property: z.string() })), - }, - handler: async (client: client, args: any) => { - return { myResponse: 'Hello world!' }; - }) -}; - -// initialize the server with your custom endpoints -init({ server: myServer, endpoints: [retrieveApplications, myCustomEndpoint] }); -``` - -## Available Tools - -The following tools are available in this MCP server. - -### Resource `applications`: - -- `retrieve_applications` (`read`): Retrieves detailed information for a specific no-code application, including its configuration and current status. -- `list_applications` (`read`): Retrieves a paginated list of no-code applications with optional filtering and sorting capabilities. -- `generate_content_applications` (`write`): Generate content from an existing no-code application with inputs. - -### Resource `applications.jobs`: - -- `create_applications_jobs` (`write`): Generate content asynchronously from an existing application with inputs. -- `retrieve_applications_jobs` (`read`): Retrieves a single job created via the Async API. -- `list_applications_jobs` (`read`): Retrieve all jobs created via the async API, linked to the provided application ID (or alias). -- `retry_applications_jobs` (`write`): Re-triggers the async execution of a single job previously created via the Async api and terminated in error. - -### Resource `applications.graphs`: - -- `update_applications_graphs` (`write`): Updates the Knowledge Graphs listed and associates them with the no-code chat app to be used. -- `list_applications_graphs` (`read`): Retrieve Knowledge Graphs associated with a no-code chat application. - -### Resource `chat`: - -- `chat_chat` (`write`): Generate a chat completion based on the provided messages. The response shown below is for non-streaming. To learn about streaming responses, see the [chat completion guide](/api-guides/chat-completion). - -### Resource `completions`: - -- `create_completions` (`write`): Text generation - -### Resource `models`: - -- `list_models` (`read`): List models - -### Resource `graphs`: - -- `create_graphs` (`write`): Create a new Knowledge Graph. -- `retrieve_graphs` (`read`): Retrieve a Knowledge Graph. -- `update_graphs` (`write`): Update the name and description of a Knowledge Graph. -- `list_graphs` (`read`): Retrieve a list of Knowledge Graphs. -- `delete_graphs` (`write`): Delete a Knowledge Graph. -- `add_file_to_graph_graphs` (`write`): Add a file to a Knowledge Graph. -- `question_graphs` (`write`): Ask a question to specified Knowledge Graphs. -- `remove_file_from_graph_graphs` (`write`): Remove a file from a Knowledge Graph. - -### Resource `files`: - -- `retrieve_files` (`read`): Retrieve file -- `list_files` (`read`): List files -- `delete_files` (`write`): Delete file -- `download_files` (`read`): Download file -- `retry_files` (`write`): Retry failed files -- `upload_files` (`write`): Upload file - -### Resource `tools`: - -- `context_aware_splitting_tools` (`write`): Splits a long block of text (maximum 4000 words) into smaller chunks while preserving the semantic meaning of the text and context between the chunks. -- `parse_pdf_tools` (`write`): Parse PDF to other formats. - -### Resource `tools.comprehend`: - -- `medical_tools_comprehend` (`write`): Analyze unstructured medical text to extract entities labeled with standardized medical codes and confidence scores. - -### Resource `vision`: - -- `analyze_vision` (`write`): Submit images and a prompt to generate an analysis of the images. diff --git a/packages/mcp-server/build b/packages/mcp-server/build deleted file mode 100644 index 6eafa29e..00000000 --- a/packages/mcp-server/build +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env bash -set -exuo pipefail - -rm -rf dist; mkdir dist - -# Copy src to dist/src and build from dist/src into dist, so that -# the source map for index.js.map will refer to ./src/index.ts etc -cp -rp src README.md dist - -for file in LICENSE; do - if [ -e "../../${file}" ]; then cp "../../${file}" dist; fi -done - -for file in CHANGELOG.md; do - if [ -e "${file}" ]; then cp "${file}" dist; fi -done - -# this converts the export map paths for the dist directory -# and does a few other minor things -PKG_JSON_PATH=../../packages/mcp-server/package.json node ../../scripts/utils/make-dist-package-json.cjs > dist/package.json - -# updates the `writer-sdk` dependency to point to NPM -node scripts/postprocess-dist-package-json.cjs - -# build to .js/.mjs/.d.ts files -npm exec tsc-multi - -cp tsconfig.dist-src.json dist/src/tsconfig.json - -# Add proper Node.js shebang to the top of the file -sed -i.bak '1s;^;#!/usr/bin/env node\n;' dist/index.js -rm dist/index.js.bak - -chmod +x dist/index.js - -DIST_PATH=./dist PKG_IMPORT_PATH=writer-sdk-mcp/ node ../../scripts/utils/postprocess-files.cjs diff --git a/packages/mcp-server/jest.config.ts b/packages/mcp-server/jest.config.ts deleted file mode 100644 index 3080925d..00000000 --- a/packages/mcp-server/jest.config.ts +++ /dev/null @@ -1,17 +0,0 @@ -import type { JestConfigWithTsJest } from 'ts-jest'; - -const config: JestConfigWithTsJest = { - preset: 'ts-jest/presets/default-esm', - testEnvironment: 'node', - transform: { - '^.+\\.(t|j)sx?$': ['@swc/jest', { sourceMaps: 'inline' }], - }, - moduleNameMapper: { - '^writer-sdk-mcp$': '/src/index.ts', - '^writer-sdk-mcp/(.*)$': '/src/$1', - }, - modulePathIgnorePatterns: ['/dist/'], - testPathIgnorePatterns: ['scripts'], -}; - -export default config; diff --git a/packages/mcp-server/package.json b/packages/mcp-server/package.json deleted file mode 100644 index e718e32f..00000000 --- a/packages/mcp-server/package.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "name": "writer-sdk-mcp", - "version": "2.1.0-rc.1", - "description": "The official MCP Server for the Writer API", - "author": "Writer ", - "types": "dist/index.d.ts", - "main": "dist/index.js", - "type": "commonjs", - "repository": "github:writer/writer-node", - "license": "Apache-2.0", - "packageManager": "yarn@1.22.22", - "private": false, - "scripts": { - "test": "jest", - "build": "bash ./build", - "prepack": "echo 'to pack, run yarn build && (cd dist; yarn pack)' && exit 1", - "prepublishOnly": "echo 'to publish, run yarn build && (cd dist; yarn publish)' && exit 1", - "format": "prettier --write --cache --cache-strategy metadata . !dist", - "prepare": "npm run build", - "tsn": "ts-node -r tsconfig-paths/register", - "lint": "eslint --ext ts,js .", - "fix": "eslint --fix --ext ts,js ." - }, - "dependencies": { - "writer-sdk": "file:../../dist/", - "@modelcontextprotocol/sdk": "^1.6.1", - "yargs": "^17.7.2" - }, - "bin": { - "mcp-server": "dist/index.js" - }, - "devDependencies": { - "@types/jest": "^29.4.0", - "@typescript-eslint/eslint-plugin": "^6.7.0", - "@typescript-eslint/parser": "^6.7.0", - "eslint": "^8.49.0", - "eslint-plugin-prettier": "^5.0.1", - "eslint-plugin-unused-imports": "^3.0.0", - "jest": "^29.4.0", - "prettier": "^3.0.0", - "ts-jest": "^29.1.0", - "ts-morph": "^19.0.0", - "ts-node": "^10.5.0", - "tsc-multi": "https://github.com/stainless-api/tsc-multi/releases/download/v1.1.3/tsc-multi.tgz", - "tsconfig-paths": "^4.0.0", - "typescript": "^4.8.2" - }, - "imports": { - "writer-sdk-mcp": ".", - "writer-sdk-mcp/*": "./src/*" - }, - "exports": { - ".": { - "require": "./dist/index.js", - "default": "./dist/index.mjs" - }, - "./*.mjs": "./dist/*.mjs", - "./*.js": "./dist/*.js", - "./*": { - "require": "./dist/*.js", - "default": "./dist/*.mjs" - } - } -} diff --git a/packages/mcp-server/scripts/postprocess-dist-package-json.cjs b/packages/mcp-server/scripts/postprocess-dist-package-json.cjs deleted file mode 100644 index 298986f8..00000000 --- a/packages/mcp-server/scripts/postprocess-dist-package-json.cjs +++ /dev/null @@ -1,12 +0,0 @@ -const fs = require('fs'); -const pkgJson = require('../dist/package.json'); -const parentPkgJson = require('../../../package.json'); - -for (const dep in pkgJson.dependencies) { - // ensure we point to NPM instead of a local directory - if (dep === 'writer-sdk') { - pkgJson.dependencies[dep] = '^' + parentPkgJson.version; - } -} - -fs.writeFileSync('dist/package.json', JSON.stringify(pkgJson, null, 2)); diff --git a/packages/mcp-server/src/index.ts b/packages/mcp-server/src/index.ts deleted file mode 100644 index fd6d7f86..00000000 --- a/packages/mcp-server/src/index.ts +++ /dev/null @@ -1,190 +0,0 @@ -import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'; -import yargs from 'yargs'; -import { hideBin } from 'yargs/helpers'; -import { init, server } from './server'; -import { endpoints, Filter, query } from './tools'; - -async function main() { - const opts = yargs(hideBin(process.argv)) - .option('tool', { - type: 'string', - array: true, - description: 'Include tools matching the specified names', - }) - .option('resource', { - type: 'string', - array: true, - description: 'Include tools matching the specified resources', - }) - .option('operation', { - type: 'string', - array: true, - choices: ['read', 'write'], - description: 'Include tools matching the specified operations', - }) - .option('tag', { - type: 'string', - array: true, - description: 'Include tools with the specified tags', - }) - .option('no-tool', { - type: 'string', - array: true, - description: 'Exclude tools matching the specified names', - }) - .option('no-resource', { - type: 'string', - array: true, - description: 'Exclude tools matching the specified resources', - }) - .option('no-operation', { - type: 'string', - array: true, - description: 'Exclude tools matching the specified operations', - }) - .option('no-tag', { - type: 'string', - array: true, - description: 'Exclude tools with the specified tags', - }) - .option('list', { - type: 'boolean', - description: 'List all tools and exit', - }) - .help(); - - for (const [command, desc] of examples()) { - opts.example(command, desc); - } - - const argv = opts.parseSync(); - - if (argv.list) { - listAllTools(); - return; - } - const filters: Filter[] = []; - - for (const tag of argv.tag || []) { - filters.push({ type: 'tag', op: 'include', value: tag }); - } - - for (const tag of argv.noTag || []) { - filters.push({ type: 'tag', op: 'exclude', value: tag }); - } - - for (const resource of argv.resource || []) { - filters.push({ type: 'resource', op: 'include', value: resource }); - } - - for (const resource of argv.noResource || []) { - filters.push({ type: 'resource', op: 'exclude', value: resource }); - } - - for (const tool of argv.tool || []) { - filters.push({ type: 'tool', op: 'include', value: tool }); - } - - for (const tool of argv.noTool || []) { - filters.push({ type: 'tool', op: 'exclude', value: tool }); - } - - for (const operation of argv.operation || []) { - filters.push({ type: 'operation', op: 'include', value: operation }); - } - - for (const operation of argv.noOperation || []) { - filters.push({ type: 'operation', op: 'exclude', value: operation }); - } - - const filteredEndpoints = query(filters, endpoints); - - if (filteredEndpoints.length === 0) { - console.error('No tools match the provided filters.'); - process.exit(1); - } - - console.error( - `MCP Server starting with ${filteredEndpoints.length} tools:`, - filteredEndpoints.map((e) => e.tool.name), - ); - - init({ server, endpoints: filteredEndpoints }); - - const transport = new StdioServerTransport(); - await server.connect(transport); - console.error('MCP Server running on stdio'); -} - -if (require.main === module) { - main().catch((error) => { - console.error('Fatal error in main():', error); - process.exit(1); - }); -} - -function listAllTools() { - if (endpoints.length === 0) { - console.error('No tools available.'); - return; - } - console.error('Available tools:\n'); - - // Group endpoints by resource - const resourceGroups = new Map(); - - for (const endpoint of endpoints) { - const resource = endpoint.metadata.resource; - if (!resourceGroups.has(resource)) { - resourceGroups.set(resource, []); - } - resourceGroups.get(resource)!.push(endpoint); - } - - // Sort resources alphabetically - const sortedResources = Array.from(resourceGroups.keys()).sort(); - - // Display hierarchically by resource - for (const resource of sortedResources) { - console.error(`Resource: ${resource}`); - - const resourceEndpoints = resourceGroups.get(resource)!; - // Sort endpoints by tool name - resourceEndpoints.sort((a, b) => a.tool.name.localeCompare(b.tool.name)); - - for (const endpoint of resourceEndpoints) { - const { - tool, - metadata: { operation, tags }, - } = endpoint; - - console.error(` - ${tool.name} (${operation}) ${tags.length > 0 ? `tags: ${tags.join(', ')}` : ''}`); - console.error(` Description: ${tool.description}`); - } - console.error(''); - } -} - -function examples(): [string, string][] { - const firstEndpoint = endpoints[0]!; - const secondEndpoint = - endpoints.find((e) => e.metadata.resource !== firstEndpoint.metadata.resource) || endpoints[1]; - const tag = endpoints.find((e) => e.metadata.tags.length > 0)?.metadata.tags[0]; - const otherEndpoint = secondEndpoint || firstEndpoint; - - return [ - [ - `--tool="${firstEndpoint.tool.name}" ${secondEndpoint ? `--tool="${secondEndpoint.tool.name}"` : ''}`, - 'Include tools by name', - ], - [ - `--resource="${firstEndpoint.metadata.resource}" --operation="read"`, - 'Filter by resource and operation', - ], - [ - `--resource="${otherEndpoint.metadata.resource}*" --no-tool="${otherEndpoint.tool.name}"`, - 'Use resource wildcards and exclusions', - ], - ...(tag ? [[`--tag="${tag}"`, 'Filter based on tags'] as [string, string]] : []), - ]; -} diff --git a/packages/mcp-server/src/server.ts b/packages/mcp-server/src/server.ts deleted file mode 100644 index db57eab1..00000000 --- a/packages/mcp-server/src/server.ts +++ /dev/null @@ -1,89 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -import { Server } from '@modelcontextprotocol/sdk/server/index.js'; -import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'; -import { endpoints, HandlerFunction } from './tools'; -import { CallToolRequestSchema, ListToolsRequestSchema, Tool } from '@modelcontextprotocol/sdk/types.js'; -import Writer from 'writer-sdk'; -export { endpoints } from './tools'; - -// Create server instance -export const server = new McpServer( - { - name: 'writer_sdk_api', - version: '2.1.0-rc.1', - }, - { - capabilities: { - tools: {}, - }, - }, -); - -/** - * Initializes the provided MCP Server with the given tools and handlers. - * If not provided, the default client, tools and handlers will be used. - */ -export function init(params: { - server: Server | McpServer; - client?: Writer; - endpoints?: { tool: Tool; handler: HandlerFunction }[]; -}) { - const server = params.server instanceof McpServer ? params.server.server : params.server; - const providedEndpoints = params.endpoints || endpoints; - const tools = providedEndpoints.map((endpoint) => endpoint.tool); - const handlers = Object.fromEntries( - providedEndpoints.map((endpoint) => [endpoint.tool.name, endpoint.handler]), - ); - - const client = params.client || new Writer({}); - - server.setRequestHandler(ListToolsRequestSchema, async () => { - return { - tools, - }; - }); - - server.setRequestHandler(CallToolRequestSchema, async (request) => { - const { name, arguments: args } = request.params; - - const handler = handlers[name]; - if (!handler) { - throw new Error(`Unknown tool: ${name}`); - } - - return executeHandler(handler, client, args); - }); -} - -/** - * Runs the provided handler with the given client and arguments. - */ -export async function executeHandler( - handler: HandlerFunction, - client: Writer, - args: Record | undefined, -) { - const result = await handler(client, args || {}); - return { - content: [ - { - type: 'text', - text: JSON.stringify(result, null, 2), - }, - ], - }; -} - -export const readEnv = (env: string): string => { - let envValue = undefined; - if (typeof (globalThis as any).process !== 'undefined') { - envValue = (globalThis as any).process.env?.[env]?.trim(); - } else if (typeof (globalThis as any).Deno !== 'undefined') { - envValue = (globalThis as any).Deno.env?.get?.(env)?.trim(); - } - if (envValue === undefined) { - throw new Error(`Environment variable ${env} is not set`); - } - return envValue; -}; diff --git a/packages/mcp-server/src/tools/applications/generate-content-applications.ts b/packages/mcp-server/src/tools/applications/generate-content-applications.ts deleted file mode 100644 index 16724238..00000000 --- a/packages/mcp-server/src/tools/applications/generate-content-applications.ts +++ /dev/null @@ -1,102 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; -import Writer from 'writer-sdk'; - -export const metadata: Metadata = { - resource: 'applications', - operation: 'write', - tags: [], -}; - -export const tool: Tool = { - name: 'generate_content_applications', - description: 'Generate content from an existing no-code application with inputs.', - inputSchema: { - type: 'object', - anyOf: [ - { - type: 'object', - properties: { - application_id: { - type: 'string', - }, - inputs: { - type: 'array', - items: { - type: 'object', - title: 'generate_application_input', - properties: { - id: { - type: 'string', - description: - 'The unique identifier for the input field from the application. All input types from the No-code application are supported (i.e. Text input, Dropdown, File upload, Image input). The identifier should be the name of the input type.', - }, - value: { - type: 'array', - description: - 'The value for the input field. \n\nIf the input type is "File upload", you must pass the `file_id` of an uploaded file. You cannot pass a file object directly. See the [file upload endpoint](/api-guides/api-reference/file-api/upload-files) for instructions on uploading files or the [list files endpoint](/api-guides/api-reference/file-api/get-all-files) for how to see a list of uploaded files and their IDs.', - items: { - type: 'string', - }, - }, - }, - required: ['id', 'value'], - }, - }, - stream: { - type: 'string', - description: - 'Indicates whether the response should be streamed. Currently only supported for research assistant applications.', - enum: [false], - }, - }, - }, - { - type: 'object', - properties: { - application_id: { - type: 'string', - }, - inputs: { - type: 'array', - items: { - type: 'object', - title: 'generate_application_input', - properties: { - id: { - type: 'string', - description: - 'The unique identifier for the input field from the application. All input types from the No-code application are supported (i.e. Text input, Dropdown, File upload, Image input). The identifier should be the name of the input type.', - }, - value: { - type: 'array', - description: - 'The value for the input field. \n\nIf the input type is "File upload", you must pass the `file_id` of an uploaded file. You cannot pass a file object directly. See the [file upload endpoint](/api-guides/api-reference/file-api/upload-files) for instructions on uploading files or the [list files endpoint](/api-guides/api-reference/file-api/get-all-files) for how to see a list of uploaded files and their IDs.', - items: { - type: 'string', - }, - }, - }, - required: ['id', 'value'], - }, - }, - stream: { - type: 'string', - description: - 'Indicates whether the response should be streamed. Currently only supported for research assistant applications.', - enum: [true], - }, - }, - }, - ], - }, -}; - -export const handler = (client: Writer, args: any) => { - const { application_id, ...body } = args; - return client.applications.generateContent(application_id, body); -}; - -export default { metadata, tool, handler }; diff --git a/packages/mcp-server/src/tools/applications/graphs/list-applications-graphs.ts b/packages/mcp-server/src/tools/applications/graphs/list-applications-graphs.ts deleted file mode 100644 index 42ef6dcf..00000000 --- a/packages/mcp-server/src/tools/applications/graphs/list-applications-graphs.ts +++ /dev/null @@ -1,31 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../../'; -import Writer from 'writer-sdk'; - -export const metadata: Metadata = { - resource: 'applications.graphs', - operation: 'read', - tags: [], -}; - -export const tool: Tool = { - name: 'list_applications_graphs', - description: 'Retrieve Knowledge Graphs associated with a no-code chat application.', - inputSchema: { - type: 'object', - properties: { - application_id: { - type: 'string', - }, - }, - }, -}; - -export const handler = (client: Writer, args: any) => { - const { application_id } = args; - return client.applications.graphs.list(application_id); -}; - -export default { metadata, tool, handler }; diff --git a/packages/mcp-server/src/tools/applications/graphs/update-applications-graphs.ts b/packages/mcp-server/src/tools/applications/graphs/update-applications-graphs.ts deleted file mode 100644 index f0424710..00000000 --- a/packages/mcp-server/src/tools/applications/graphs/update-applications-graphs.ts +++ /dev/null @@ -1,41 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../../'; -import Writer from 'writer-sdk'; - -export const metadata: Metadata = { - resource: 'applications.graphs', - operation: 'write', - tags: [], -}; - -export const tool: Tool = { - name: 'update_applications_graphs', - description: - 'Updates the Knowledge Graphs listed and associates them with the no-code chat app to be used.', - inputSchema: { - type: 'object', - properties: { - application_id: { - type: 'string', - }, - graph_ids: { - type: 'array', - description: - 'A list of Knowledge Graph IDs to associate with the application. Note that this will replace the existing list of Knowledge Graphs associated with the application, not add to it.', - items: { - type: 'string', - description: 'The unique identifier for the Knowledge Graph.', - }, - }, - }, - }, -}; - -export const handler = (client: Writer, args: any) => { - const { application_id, ...body } = args; - return client.applications.graphs.update(application_id, body); -}; - -export default { metadata, tool, handler }; diff --git a/packages/mcp-server/src/tools/applications/jobs/create-applications-jobs.ts b/packages/mcp-server/src/tools/applications/jobs/create-applications-jobs.ts deleted file mode 100644 index 57e4c136..00000000 --- a/packages/mcp-server/src/tools/applications/jobs/create-applications-jobs.ts +++ /dev/null @@ -1,55 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../../'; -import Writer from 'writer-sdk'; - -export const metadata: Metadata = { - resource: 'applications.jobs', - operation: 'write', - tags: [], -}; - -export const tool: Tool = { - name: 'create_applications_jobs', - description: 'Generate content asynchronously from an existing application with inputs.', - inputSchema: { - type: 'object', - properties: { - application_id: { - type: 'string', - }, - inputs: { - type: 'array', - description: 'A list of input objects to generate content for.', - items: { - type: 'object', - title: 'generate_application_input', - properties: { - id: { - type: 'string', - description: - 'The unique identifier for the input field from the application. All input types from the No-code application are supported (i.e. Text input, Dropdown, File upload, Image input). The identifier should be the name of the input type.', - }, - value: { - type: 'array', - description: - 'The value for the input field. \n\nIf the input type is "File upload", you must pass the `file_id` of an uploaded file. You cannot pass a file object directly. See the [file upload endpoint](/api-guides/api-reference/file-api/upload-files) for instructions on uploading files or the [list files endpoint](/api-guides/api-reference/file-api/get-all-files) for how to see a list of uploaded files and their IDs.', - items: { - type: 'string', - }, - }, - }, - required: ['id', 'value'], - }, - }, - }, - }, -}; - -export const handler = (client: Writer, args: any) => { - const { application_id, ...body } = args; - return client.applications.jobs.create(application_id, body); -}; - -export default { metadata, tool, handler }; diff --git a/packages/mcp-server/src/tools/applications/jobs/list-applications-jobs.ts b/packages/mcp-server/src/tools/applications/jobs/list-applications-jobs.ts deleted file mode 100644 index 1cf227d7..00000000 --- a/packages/mcp-server/src/tools/applications/jobs/list-applications-jobs.ts +++ /dev/null @@ -1,46 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../../'; -import Writer from 'writer-sdk'; - -export const metadata: Metadata = { - resource: 'applications.jobs', - operation: 'read', - tags: [], -}; - -export const tool: Tool = { - name: 'list_applications_jobs', - description: - 'Retrieve all jobs created via the async API, linked to the provided application ID (or alias).', - inputSchema: { - type: 'object', - properties: { - application_id: { - type: 'string', - }, - limit: { - type: 'integer', - description: 'The pagination limit for retrieving the jobs.', - }, - offset: { - type: 'integer', - description: 'The pagination offset for retrieving the jobs.', - }, - status: { - type: 'string', - title: 'api_job_status', - description: 'The status of the job.', - enum: ['in_progress', 'failed', 'completed'], - }, - }, - }, -}; - -export const handler = (client: Writer, args: any) => { - const { application_id, ...body } = args; - return client.applications.jobs.list(application_id, body); -}; - -export default { metadata, tool, handler }; diff --git a/packages/mcp-server/src/tools/applications/jobs/retrieve-applications-jobs.ts b/packages/mcp-server/src/tools/applications/jobs/retrieve-applications-jobs.ts deleted file mode 100644 index fc742636..00000000 --- a/packages/mcp-server/src/tools/applications/jobs/retrieve-applications-jobs.ts +++ /dev/null @@ -1,31 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../../'; -import Writer from 'writer-sdk'; - -export const metadata: Metadata = { - resource: 'applications.jobs', - operation: 'read', - tags: [], -}; - -export const tool: Tool = { - name: 'retrieve_applications_jobs', - description: 'Retrieves a single job created via the Async API.', - inputSchema: { - type: 'object', - properties: { - job_id: { - type: 'string', - }, - }, - }, -}; - -export const handler = (client: Writer, args: any) => { - const { job_id } = args; - return client.applications.jobs.retrieve(job_id); -}; - -export default { metadata, tool, handler }; diff --git a/packages/mcp-server/src/tools/applications/jobs/retry-applications-jobs.ts b/packages/mcp-server/src/tools/applications/jobs/retry-applications-jobs.ts deleted file mode 100644 index 7bd34357..00000000 --- a/packages/mcp-server/src/tools/applications/jobs/retry-applications-jobs.ts +++ /dev/null @@ -1,32 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../../'; -import Writer from 'writer-sdk'; - -export const metadata: Metadata = { - resource: 'applications.jobs', - operation: 'write', - tags: [], -}; - -export const tool: Tool = { - name: 'retry_applications_jobs', - description: - 'Re-triggers the async execution of a single job previously created via the Async api and terminated in error.', - inputSchema: { - type: 'object', - properties: { - job_id: { - type: 'string', - }, - }, - }, -}; - -export const handler = (client: Writer, args: any) => { - const { job_id } = args; - return client.applications.jobs.retry(job_id); -}; - -export default { metadata, tool, handler }; diff --git a/packages/mcp-server/src/tools/applications/list-applications.ts b/packages/mcp-server/src/tools/applications/list-applications.ts deleted file mode 100644 index 76a9ef5a..00000000 --- a/packages/mcp-server/src/tools/applications/list-applications.ts +++ /dev/null @@ -1,52 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; -import Writer from 'writer-sdk'; - -export const metadata: Metadata = { - resource: 'applications', - operation: 'read', - tags: [], -}; - -export const tool: Tool = { - name: 'list_applications', - description: - 'Retrieves a paginated list of no-code applications with optional filtering and sorting capabilities.', - inputSchema: { - type: 'object', - properties: { - after: { - type: 'string', - description: 'Return results after this application ID for pagination.', - }, - before: { - type: 'string', - description: 'Return results before this application ID for pagination.', - }, - limit: { - type: 'integer', - description: 'Maximum number of applications to return in the response.', - }, - order: { - type: 'string', - description: 'Sort order for the results based on creation time.', - enum: ['asc', 'desc'], - }, - type: { - type: 'string', - title: 'application_type', - description: 'Filter applications by their type.', - enum: ['generation'], - }, - }, - }, -}; - -export const handler = (client: Writer, args: any) => { - const { ...body } = args; - return client.applications.list(body); -}; - -export default { metadata, tool, handler }; diff --git a/packages/mcp-server/src/tools/applications/retrieve-applications.ts b/packages/mcp-server/src/tools/applications/retrieve-applications.ts deleted file mode 100644 index 13dadf43..00000000 --- a/packages/mcp-server/src/tools/applications/retrieve-applications.ts +++ /dev/null @@ -1,32 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; -import Writer from 'writer-sdk'; - -export const metadata: Metadata = { - resource: 'applications', - operation: 'read', - tags: [], -}; - -export const tool: Tool = { - name: 'retrieve_applications', - description: - 'Retrieves detailed information for a specific no-code application, including its configuration and current status.', - inputSchema: { - type: 'object', - properties: { - application_id: { - type: 'string', - }, - }, - }, -}; - -export const handler = (client: Writer, args: any) => { - const { application_id } = args; - return client.applications.retrieve(application_id); -}; - -export default { metadata, tool, handler }; diff --git a/packages/mcp-server/src/tools/chat/chat-chat.ts b/packages/mcp-server/src/tools/chat/chat-chat.ts deleted file mode 100644 index c841af20..00000000 --- a/packages/mcp-server/src/tools/chat/chat-chat.ts +++ /dev/null @@ -1,513 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; -import Writer from 'writer-sdk'; - -export const metadata: Metadata = { - resource: 'chat', - operation: 'write', - tags: [], -}; - -export const tool: Tool = { - name: 'chat_chat', - description: - 'Generate a chat completion based on the provided messages. The response shown below is for non-streaming. To learn about streaming responses, see the [chat completion guide](/api-guides/chat-completion).', - inputSchema: { - type: 'object', - anyOf: [ - { - type: 'object', - properties: { - messages: { - type: 'array', - description: - 'An array of message objects that form the conversation history or context for the model to respond to. The array must contain at least one message.', - items: { - type: 'object', - properties: { - role: { - type: 'string', - description: - 'The role of the chat message. You can provide a system prompt by setting the role to `system`, or specify that a message is the result of a [tool call](/api-guides/tool-calling) by setting the role to `tool`.', - enum: ['user', 'assistant', 'system', 'tool'], - }, - content: { - type: 'string', - }, - graph_data: { - type: 'object', - title: 'graph_data', - properties: { - sources: { - type: 'array', - items: { - type: 'object', - title: 'source', - properties: { - file_id: { - type: 'string', - description: 'The unique identifier of the file.', - }, - snippet: { - type: 'string', - description: 'A snippet of text from the source file.', - }, - }, - required: ['file_id', 'snippet'], - }, - }, - status: { - type: 'string', - title: 'graph_stage_status', - enum: ['processing', 'finished'], - }, - subqueries: { - type: 'array', - items: { - type: 'object', - title: 'sub_query', - properties: { - answer: { - type: 'string', - description: 'The answer to the subquery.', - }, - query: { - type: 'string', - description: 'The subquery that was asked.', - }, - sources: { - type: 'array', - items: { - $ref: '#/anyOf/0/properties/messages/items/graph_data/sources/items', - }, - }, - }, - required: ['answer', 'query', 'sources'], - }, - }, - }, - required: [], - }, - name: { - type: 'string', - }, - refusal: { - type: 'string', - }, - tool_call_id: { - type: 'string', - }, - tool_calls: { - type: 'array', - items: { - type: 'object', - title: 'tool_call', - properties: { - id: { - type: 'string', - }, - function: { - type: 'object', - title: 'function', - properties: { - arguments: { - type: 'string', - }, - name: { - type: 'string', - }, - }, - required: ['arguments'], - }, - type: { - type: 'string', - enum: ['function'], - }, - index: { - type: 'integer', - }, - }, - required: ['id', 'function', 'type'], - }, - }, - }, - required: ['role'], - }, - }, - model: { - type: 'string', - description: - 'Specifies the model to be used for generating responses. The chat model is always `palmyra-x-004` for conversational use.', - }, - logprobs: { - type: 'boolean', - description: 'Specifies whether to return log probabilities of the output tokens.', - }, - max_tokens: { - type: 'integer', - description: - 'Defines the maximum number of tokens (words and characters) that the model can generate in the response. The default value is set to 16, but it can be adjusted to allow for longer or shorter responses as needed.', - }, - n: { - type: 'integer', - description: - 'Specifies the number of completions (responses) to generate from the model in a single request. This parameter allows multiple responses to be generated, offering a variety of potential replies from which to choose.', - }, - stop: { - anyOf: [ - { - type: 'array', - items: { - type: 'string', - }, - }, - { - type: 'string', - }, - ], - description: - 'A token or sequence of tokens that, when generated, will cause the model to stop producing further content. This can be a single token or an array of tokens, acting as a signal to end the output.', - }, - stream: { - type: 'string', - description: - 'Indicates whether the response should be streamed incrementally as it is generated or only returned once fully complete. Streaming can be useful for providing real-time feedback in interactive applications.', - enum: [false], - }, - stream_options: { - type: 'object', - title: 'stream_options', - description: 'Additional options for streaming.', - properties: { - include_usage: { - type: 'boolean', - description: 'Indicate whether to include usage information.', - }, - }, - required: ['include_usage'], - }, - temperature: { - type: 'number', - description: - "Controls the randomness or creativity of the model's responses. A higher temperature results in more varied and less predictable text, while a lower temperature produces more deterministic and conservative outputs.", - }, - tool_choice: { - anyOf: [ - { - type: 'object', - title: 'String', - properties: { - value: { - type: 'string', - title: 'string_tool_choice_options', - enum: ['none', 'auto', 'required'], - }, - }, - required: ['value'], - }, - { - type: 'object', - title: 'JSON object', - properties: { - value: { - type: 'object', - }, - }, - required: ['value'], - }, - ], - description: - 'Configure how the model will call functions: `auto` will allow the model to automatically choose the best tool, `none` disables tool calling. You can also pass a specific previously defined function.', - }, - tools: { - type: 'array', - description: - 'An array containing tool definitions for tools that the model can use to generate responses. The tool definitions use JSON schema. You can define your own functions or use one of the built-in `graph`, `llm`, or `vision` tools. Note that you can only use one built-in tool type in the array (only one of `graph`, `llm`, or `vision`).', - items: { - anyOf: [ - { - type: 'object', - title: 'Function tool', - properties: { - function: { - type: 'object', - title: 'tool_function', - description: 'A tool that uses a custom function.', - properties: { - name: { - type: 'string', - description: 'Name of the function.', - }, - description: { - type: 'string', - description: 'Description of the function.', - }, - parameters: { - type: 'object', - description: 'The parameters of the function.', - }, - }, - required: ['name'], - }, - type: { - type: 'string', - description: 'The type of tool.', - enum: ['function'], - }, - }, - required: ['function', 'type'], - }, - { - type: 'object', - title: 'Graph tool', - properties: { - function: { - type: 'object', - title: 'graph_function', - description: 'A tool that uses Knowledge Graphs as context for responses.', - properties: { - graph_ids: { - type: 'array', - description: 'An array of graph IDs to be used in the tool.', - items: { - type: 'string', - }, - }, - subqueries: { - type: 'boolean', - description: 'Boolean to indicate whether to include subqueries in the response.', - }, - description: { - type: 'string', - description: 'A description of the graph content.', - }, - }, - required: ['graph_ids', 'subqueries'], - }, - type: { - type: 'string', - description: 'The type of tool.', - enum: ['graph'], - }, - }, - required: ['function', 'type'], - }, - { - type: 'object', - title: 'LLM tool', - properties: { - function: { - type: 'object', - title: 'LLM function', - description: 'A tool that uses another Writer model to generate a response.', - properties: { - description: { - type: 'string', - description: 'A description of the model to be used.', - }, - model: { - type: 'string', - description: 'The model to be used.', - }, - }, - required: ['description', 'model'], - }, - type: { - type: 'string', - description: 'The type of tool.', - enum: ['llm'], - }, - }, - required: ['function', 'type'], - }, - { - type: 'object', - title: 'Vision tool', - properties: { - function: { - type: 'object', - title: 'Vision function', - description: 'A tool that uses Palmyra Vision to analyze images.', - properties: { - model: { - type: 'string', - description: 'The model to be used for image analysis. Must be `palmyra-vision`.', - }, - variables: { - type: 'array', - items: { - type: 'object', - title: 'Vision Tool Request File Variable', - properties: { - file_id: { - type: 'string', - description: - 'The File ID of the image to be analyzed. The file must be uploaded to the Writer platform before you use it with the Vision tool.', - }, - name: { - type: 'string', - description: - 'The name of the file variable. You must reference this name in the `message.content` field of the request to the chat completions endpoint. Use double curly braces (`{{}}`) to reference the file. For example, `Describe the difference between the image {{image_1}} and the image {{image_2}}`.', - }, - }, - required: ['file_id', 'name'], - }, - }, - }, - required: ['model', 'variables'], - }, - type: { - type: 'string', - description: 'The type of tool.', - enum: ['vision'], - }, - }, - required: ['function', 'type'], - }, - ], - }, - }, - top_p: { - type: 'number', - description: - 'Sets the threshold for "nucleus sampling," a technique to focus the model\'s token generation on the most likely subset of tokens. Only tokens with cumulative probability above this threshold are considered, controlling the trade-off between creativity and coherence.', - }, - }, - }, - { - type: 'object', - properties: { - messages: { - type: 'array', - description: - 'An array of message objects that form the conversation history or context for the model to respond to. The array must contain at least one message.', - items: { - type: 'object', - properties: { - role: { - type: 'string', - description: - 'The role of the chat message. You can provide a system prompt by setting the role to `system`, or specify that a message is the result of a [tool call](/api-guides/tool-calling) by setting the role to `tool`.', - enum: ['user', 'assistant', 'system', 'tool'], - }, - content: { - type: 'string', - }, - graph_data: { - $ref: '#/anyOf/0/properties/messages/items/graph_data', - }, - name: { - type: 'string', - }, - refusal: { - type: 'string', - }, - tool_call_id: { - type: 'string', - }, - tool_calls: { - type: 'array', - items: { - $ref: '#/anyOf/0/properties/messages/items/tool_calls/items', - }, - }, - }, - required: ['role'], - }, - }, - model: { - type: 'string', - description: - 'Specifies the model to be used for generating responses. The chat model is always `palmyra-x-004` for conversational use.', - }, - stream: { - type: 'string', - description: - 'Indicates whether the response should be streamed incrementally as it is generated or only returned once fully complete. Streaming can be useful for providing real-time feedback in interactive applications.', - enum: [true], - }, - logprobs: { - type: 'boolean', - description: 'Specifies whether to return log probabilities of the output tokens.', - }, - max_tokens: { - type: 'integer', - description: - 'Defines the maximum number of tokens (words and characters) that the model can generate in the response. The default value is set to 16, but it can be adjusted to allow for longer or shorter responses as needed.', - }, - n: { - type: 'integer', - description: - 'Specifies the number of completions (responses) to generate from the model in a single request. This parameter allows multiple responses to be generated, offering a variety of potential replies from which to choose.', - }, - stop: { - anyOf: [ - { - type: 'array', - items: { - type: 'string', - }, - }, - { - type: 'string', - }, - ], - description: - 'A token or sequence of tokens that, when generated, will cause the model to stop producing further content. This can be a single token or an array of tokens, acting as a signal to end the output.', - }, - stream_options: { - type: 'object', - title: 'stream_options', - description: 'Additional options for streaming.', - properties: { - include_usage: { - type: 'boolean', - description: 'Indicate whether to include usage information.', - }, - }, - required: ['include_usage'], - }, - temperature: { - type: 'number', - description: - "Controls the randomness or creativity of the model's responses. A higher temperature results in more varied and less predictable text, while a lower temperature produces more deterministic and conservative outputs.", - }, - tool_choice: { - anyOf: [ - { - $ref: '#/anyOf/0/properties/tool_choice/anyOf/0', - }, - { - $ref: '#/anyOf/0/properties/tool_choice/anyOf/1', - }, - ], - description: - 'Configure how the model will call functions: `auto` will allow the model to automatically choose the best tool, `none` disables tool calling. You can also pass a specific previously defined function.', - }, - tools: { - type: 'array', - description: - 'An array containing tool definitions for tools that the model can use to generate responses. The tool definitions use JSON schema. You can define your own functions or use one of the built-in `graph`, `llm`, or `vision` tools. Note that you can only use one built-in tool type in the array (only one of `graph`, `llm`, or `vision`).', - items: { - $ref: '#/anyOf/0/properties/tools/items', - }, - }, - top_p: { - type: 'number', - description: - 'Sets the threshold for "nucleus sampling," a technique to focus the model\'s token generation on the most likely subset of tokens. Only tokens with cumulative probability above this threshold are considered, controlling the trade-off between creativity and coherence.', - }, - }, - }, - ], - }, -}; - -export const handler = (client: Writer, args: any) => { - const { ...body } = args; - return client.chat.chat(body); -}; - -export default { metadata, tool, handler }; diff --git a/packages/mcp-server/src/tools/completions/create-completions.ts b/packages/mcp-server/src/tools/completions/create-completions.ts deleted file mode 100644 index 728ee3e0..00000000 --- a/packages/mcp-server/src/tools/completions/create-completions.ts +++ /dev/null @@ -1,144 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; -import Writer from 'writer-sdk'; - -export const metadata: Metadata = { - resource: 'completions', - operation: 'write', - tags: [], -}; - -export const tool: Tool = { - name: 'create_completions', - description: 'Text generation', - inputSchema: { - type: 'object', - anyOf: [ - { - type: 'object', - properties: { - model: { - type: 'string', - description: 'The identifier of the model to be used for processing the request.', - }, - prompt: { - type: 'string', - description: 'The input text that the model will process to generate a response.', - }, - best_of: { - type: 'integer', - description: - 'Specifies the number of completions to generate and return the best one. Useful for generating multiple outputs and choosing the best based on some criteria.', - }, - max_tokens: { - type: 'integer', - description: 'The maximum number of tokens that the model can generate in the response.', - }, - random_seed: { - type: 'integer', - description: - 'A seed used to initialize the random number generator for the model, ensuring reproducibility of the output when the same inputs are provided.', - }, - stop: { - anyOf: [ - { - type: 'array', - items: { - type: 'string', - }, - }, - { - type: 'string', - }, - ], - description: - "Specifies stopping conditions for the model's output generation. This can be an array of strings or a single string that the model will look for as a signal to stop generating further tokens.", - }, - stream: { - type: 'string', - description: - "Determines whether the model's output should be streamed. If true, the output is generated and sent incrementally, which can be useful for real-time applications.", - enum: [false], - }, - temperature: { - type: 'number', - description: - "Controls the randomness of the model's outputs. Higher values lead to more random outputs, while lower values make the model more deterministic.", - }, - top_p: { - type: 'number', - description: - 'Used to control the nucleus sampling, where only the most probable tokens with a cumulative probability of top_p are considered for sampling, providing a way to fine-tune the randomness of predictions.', - }, - }, - }, - { - type: 'object', - properties: { - model: { - type: 'string', - description: 'The identifier of the model to be used for processing the request.', - }, - prompt: { - type: 'string', - description: 'The input text that the model will process to generate a response.', - }, - stream: { - type: 'string', - description: - "Determines whether the model's output should be streamed. If true, the output is generated and sent incrementally, which can be useful for real-time applications.", - enum: [true], - }, - best_of: { - type: 'integer', - description: - 'Specifies the number of completions to generate and return the best one. Useful for generating multiple outputs and choosing the best based on some criteria.', - }, - max_tokens: { - type: 'integer', - description: 'The maximum number of tokens that the model can generate in the response.', - }, - random_seed: { - type: 'integer', - description: - 'A seed used to initialize the random number generator for the model, ensuring reproducibility of the output when the same inputs are provided.', - }, - stop: { - anyOf: [ - { - type: 'array', - items: { - type: 'string', - }, - }, - { - type: 'string', - }, - ], - description: - "Specifies stopping conditions for the model's output generation. This can be an array of strings or a single string that the model will look for as a signal to stop generating further tokens.", - }, - temperature: { - type: 'number', - description: - "Controls the randomness of the model's outputs. Higher values lead to more random outputs, while lower values make the model more deterministic.", - }, - top_p: { - type: 'number', - description: - 'Used to control the nucleus sampling, where only the most probable tokens with a cumulative probability of top_p are considered for sampling, providing a way to fine-tune the randomness of predictions.', - }, - }, - }, - ], - }, -}; - -export const handler = (client: Writer, args: any) => { - const { ...body } = args; - return client.completions.create(body); -}; - -export default { metadata, tool, handler }; diff --git a/packages/mcp-server/src/tools/files/delete-files.ts b/packages/mcp-server/src/tools/files/delete-files.ts deleted file mode 100644 index 43db0856..00000000 --- a/packages/mcp-server/src/tools/files/delete-files.ts +++ /dev/null @@ -1,31 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; -import Writer from 'writer-sdk'; - -export const metadata: Metadata = { - resource: 'files', - operation: 'write', - tags: [], -}; - -export const tool: Tool = { - name: 'delete_files', - description: 'Delete file', - inputSchema: { - type: 'object', - properties: { - file_id: { - type: 'string', - }, - }, - }, -}; - -export const handler = (client: Writer, args: any) => { - const { file_id } = args; - return client.files.delete(file_id); -}; - -export default { metadata, tool, handler }; diff --git a/packages/mcp-server/src/tools/files/download-files.ts b/packages/mcp-server/src/tools/files/download-files.ts deleted file mode 100644 index eb6c2b98..00000000 --- a/packages/mcp-server/src/tools/files/download-files.ts +++ /dev/null @@ -1,31 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; -import Writer from 'writer-sdk'; - -export const metadata: Metadata = { - resource: 'files', - operation: 'read', - tags: [], -}; - -export const tool: Tool = { - name: 'download_files', - description: 'Download file', - inputSchema: { - type: 'object', - properties: { - file_id: { - type: 'string', - }, - }, - }, -}; - -export const handler = (client: Writer, args: any) => { - const { file_id } = args; - return client.files.download(file_id); -}; - -export default { metadata, tool, handler }; diff --git a/packages/mcp-server/src/tools/files/list-files.ts b/packages/mcp-server/src/tools/files/list-files.ts deleted file mode 100644 index 233ca7ff..00000000 --- a/packages/mcp-server/src/tools/files/list-files.ts +++ /dev/null @@ -1,59 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; -import Writer from 'writer-sdk'; - -export const metadata: Metadata = { - resource: 'files', - operation: 'read', - tags: [], -}; - -export const tool: Tool = { - name: 'list_files', - description: 'List files', - inputSchema: { - type: 'object', - properties: { - after: { - type: 'string', - description: - 'The ID of the last object in the previous page. This parameter instructs the API to return the next page of results.', - }, - before: { - type: 'string', - description: - 'The ID of the first object in the previous page. This parameter instructs the API to return the previous page of results.', - }, - graph_id: { - type: 'string', - description: 'The unique identifier of the graph to which the files belong.', - }, - limit: { - type: 'integer', - description: - 'Specifies the maximum number of objects returned in a page. The default value is 50. The minimum value is 1, and the maximum value is 100.', - }, - order: { - type: 'string', - description: - 'Specifies the order of the results. Valid values are asc for ascending and desc for descending.', - enum: ['asc', 'desc'], - }, - status: { - type: 'string', - description: - 'Specifies the status of the files to retrieve. Valid values are in_progress, completed or failed.', - enum: ['in_progress', 'completed', 'failed'], - }, - }, - }, -}; - -export const handler = (client: Writer, args: any) => { - const { ...body } = args; - return client.files.list(body); -}; - -export default { metadata, tool, handler }; diff --git a/packages/mcp-server/src/tools/files/retrieve-files.ts b/packages/mcp-server/src/tools/files/retrieve-files.ts deleted file mode 100644 index 279fed7d..00000000 --- a/packages/mcp-server/src/tools/files/retrieve-files.ts +++ /dev/null @@ -1,31 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; -import Writer from 'writer-sdk'; - -export const metadata: Metadata = { - resource: 'files', - operation: 'read', - tags: [], -}; - -export const tool: Tool = { - name: 'retrieve_files', - description: 'Retrieve file', - inputSchema: { - type: 'object', - properties: { - file_id: { - type: 'string', - }, - }, - }, -}; - -export const handler = (client: Writer, args: any) => { - const { file_id } = args; - return client.files.retrieve(file_id); -}; - -export default { metadata, tool, handler }; diff --git a/packages/mcp-server/src/tools/files/retry-files.ts b/packages/mcp-server/src/tools/files/retry-files.ts deleted file mode 100644 index 1805d966..00000000 --- a/packages/mcp-server/src/tools/files/retry-files.ts +++ /dev/null @@ -1,35 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; -import Writer from 'writer-sdk'; - -export const metadata: Metadata = { - resource: 'files', - operation: 'write', - tags: [], -}; - -export const tool: Tool = { - name: 'retry_files', - description: 'Retry failed files', - inputSchema: { - type: 'object', - properties: { - file_ids: { - type: 'array', - description: 'The unique identifier of the files to be retried.', - items: { - type: 'string', - }, - }, - }, - }, -}; - -export const handler = (client: Writer, args: any) => { - const { ...body } = args; - return client.files.retry(body); -}; - -export default { metadata, tool, handler }; diff --git a/packages/mcp-server/src/tools/files/upload-files.ts b/packages/mcp-server/src/tools/files/upload-files.ts deleted file mode 100644 index e78a5e8e..00000000 --- a/packages/mcp-server/src/tools/files/upload-files.ts +++ /dev/null @@ -1,34 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; -import Writer from 'writer-sdk'; - -export const metadata: Metadata = { - resource: 'files', - operation: 'write', - tags: [], -}; - -export const tool: Tool = { - name: 'upload_files', - description: 'Upload file', - inputSchema: { - type: 'object', - properties: { - content: { - type: 'string', - }, - 'Content-Disposition': { - type: 'string', - }, - }, - }, -}; - -export const handler = (client: Writer, args: any) => { - const { ...body } = args; - return client.files.upload(body); -}; - -export default { metadata, tool, handler }; diff --git a/packages/mcp-server/src/tools/graphs/add-file-to-graph-graphs.ts b/packages/mcp-server/src/tools/graphs/add-file-to-graph-graphs.ts deleted file mode 100644 index d46a9f8f..00000000 --- a/packages/mcp-server/src/tools/graphs/add-file-to-graph-graphs.ts +++ /dev/null @@ -1,35 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; -import Writer from 'writer-sdk'; - -export const metadata: Metadata = { - resource: 'graphs', - operation: 'write', - tags: [], -}; - -export const tool: Tool = { - name: 'add_file_to_graph_graphs', - description: 'Add a file to a Knowledge Graph.', - inputSchema: { - type: 'object', - properties: { - graph_id: { - type: 'string', - }, - file_id: { - type: 'string', - description: 'The unique identifier of the file.', - }, - }, - }, -}; - -export const handler = (client: Writer, args: any) => { - const { graph_id, ...body } = args; - return client.graphs.addFileToGraph(graph_id, body); -}; - -export default { metadata, tool, handler }; diff --git a/packages/mcp-server/src/tools/graphs/create-graphs.ts b/packages/mcp-server/src/tools/graphs/create-graphs.ts deleted file mode 100644 index 16eaae0b..00000000 --- a/packages/mcp-server/src/tools/graphs/create-graphs.ts +++ /dev/null @@ -1,38 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; -import Writer from 'writer-sdk'; - -export const metadata: Metadata = { - resource: 'graphs', - operation: 'write', - tags: [], -}; - -export const tool: Tool = { - name: 'create_graphs', - description: 'Create a new Knowledge Graph.', - inputSchema: { - type: 'object', - properties: { - description: { - type: 'string', - description: - 'A description of the Knowledge Graph (max 255 characters). Omitting this field leaves the description unchanged.', - }, - name: { - type: 'string', - description: - 'The name of the Knowledge Graph (max 255 characters). Omitting this field leaves the name unchanged.', - }, - }, - }, -}; - -export const handler = (client: Writer, args: any) => { - const { ...body } = args; - return client.graphs.create(body); -}; - -export default { metadata, tool, handler }; diff --git a/packages/mcp-server/src/tools/graphs/delete-graphs.ts b/packages/mcp-server/src/tools/graphs/delete-graphs.ts deleted file mode 100644 index f6b80575..00000000 --- a/packages/mcp-server/src/tools/graphs/delete-graphs.ts +++ /dev/null @@ -1,31 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; -import Writer from 'writer-sdk'; - -export const metadata: Metadata = { - resource: 'graphs', - operation: 'write', - tags: [], -}; - -export const tool: Tool = { - name: 'delete_graphs', - description: 'Delete a Knowledge Graph.', - inputSchema: { - type: 'object', - properties: { - graph_id: { - type: 'string', - }, - }, - }, -}; - -export const handler = (client: Writer, args: any) => { - const { graph_id } = args; - return client.graphs.delete(graph_id); -}; - -export default { metadata, tool, handler }; diff --git a/packages/mcp-server/src/tools/graphs/list-graphs.ts b/packages/mcp-server/src/tools/graphs/list-graphs.ts deleted file mode 100644 index 9cd8ce98..00000000 --- a/packages/mcp-server/src/tools/graphs/list-graphs.ts +++ /dev/null @@ -1,49 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; -import Writer from 'writer-sdk'; - -export const metadata: Metadata = { - resource: 'graphs', - operation: 'read', - tags: [], -}; - -export const tool: Tool = { - name: 'list_graphs', - description: 'Retrieve a list of Knowledge Graphs.', - inputSchema: { - type: 'object', - properties: { - after: { - type: 'string', - description: - 'The ID of the last object in the previous page. This parameter instructs the API to return the next page of results.', - }, - before: { - type: 'string', - description: - 'The ID of the first object in the previous page. This parameter instructs the API to return the previous page of results.', - }, - limit: { - type: 'integer', - description: - 'Specifies the maximum number of objects returned in a page. The default value is 50. The minimum value is 1, and the maximum value is 100.', - }, - order: { - type: 'string', - description: - 'Specifies the order of the results. Valid values are asc for ascending and desc for descending.', - enum: ['asc', 'desc'], - }, - }, - }, -}; - -export const handler = (client: Writer, args: any) => { - const { ...body } = args; - return client.graphs.list(body); -}; - -export default { metadata, tool, handler }; diff --git a/packages/mcp-server/src/tools/graphs/question-graphs.ts b/packages/mcp-server/src/tools/graphs/question-graphs.ts deleted file mode 100644 index ae5d32c2..00000000 --- a/packages/mcp-server/src/tools/graphs/question-graphs.ts +++ /dev/null @@ -1,80 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; -import Writer from 'writer-sdk'; - -export const metadata: Metadata = { - resource: 'graphs', - operation: 'write', - tags: [], -}; - -export const tool: Tool = { - name: 'question_graphs', - description: 'Ask a question to specified Knowledge Graphs.', - inputSchema: { - type: 'object', - anyOf: [ - { - type: 'object', - properties: { - graph_ids: { - type: 'array', - description: 'The unique identifiers of the Knowledge Graphs to be queried.', - items: { - type: 'string', - }, - }, - question: { - type: 'string', - description: 'The question to be answered using the Knowledge Graph.', - }, - stream: { - type: 'string', - description: - "Determines whether the model's output should be streamed. If true, the output is generated and sent incrementally, which can be useful for real-time applications.", - enum: [false], - }, - subqueries: { - type: 'boolean', - description: 'Specify whether to include subqueries.', - }, - }, - }, - { - type: 'object', - properties: { - graph_ids: { - type: 'array', - description: 'The unique identifiers of the Knowledge Graphs to be queried.', - items: { - type: 'string', - }, - }, - question: { - type: 'string', - description: 'The question to be answered using the Knowledge Graph.', - }, - stream: { - type: 'string', - description: - "Determines whether the model's output should be streamed. If true, the output is generated and sent incrementally, which can be useful for real-time applications.", - enum: [true], - }, - subqueries: { - type: 'boolean', - description: 'Specify whether to include subqueries.', - }, - }, - }, - ], - }, -}; - -export const handler = (client: Writer, args: any) => { - const { ...body } = args; - return client.graphs.question(body); -}; - -export default { metadata, tool, handler }; diff --git a/packages/mcp-server/src/tools/graphs/remove-file-from-graph-graphs.ts b/packages/mcp-server/src/tools/graphs/remove-file-from-graph-graphs.ts deleted file mode 100644 index e52690dd..00000000 --- a/packages/mcp-server/src/tools/graphs/remove-file-from-graph-graphs.ts +++ /dev/null @@ -1,34 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; -import Writer from 'writer-sdk'; - -export const metadata: Metadata = { - resource: 'graphs', - operation: 'write', - tags: [], -}; - -export const tool: Tool = { - name: 'remove_file_from_graph_graphs', - description: 'Remove a file from a Knowledge Graph.', - inputSchema: { - type: 'object', - properties: { - graph_id: { - type: 'string', - }, - file_id: { - type: 'string', - }, - }, - }, -}; - -export const handler = (client: Writer, args: any) => { - const { file_id, ...body } = args; - return client.graphs.removeFileFromGraph(file_id, body); -}; - -export default { metadata, tool, handler }; diff --git a/packages/mcp-server/src/tools/graphs/retrieve-graphs.ts b/packages/mcp-server/src/tools/graphs/retrieve-graphs.ts deleted file mode 100644 index f5ad7058..00000000 --- a/packages/mcp-server/src/tools/graphs/retrieve-graphs.ts +++ /dev/null @@ -1,31 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; -import Writer from 'writer-sdk'; - -export const metadata: Metadata = { - resource: 'graphs', - operation: 'read', - tags: [], -}; - -export const tool: Tool = { - name: 'retrieve_graphs', - description: 'Retrieve a Knowledge Graph.', - inputSchema: { - type: 'object', - properties: { - graph_id: { - type: 'string', - }, - }, - }, -}; - -export const handler = (client: Writer, args: any) => { - const { graph_id } = args; - return client.graphs.retrieve(graph_id); -}; - -export default { metadata, tool, handler }; diff --git a/packages/mcp-server/src/tools/graphs/update-graphs.ts b/packages/mcp-server/src/tools/graphs/update-graphs.ts deleted file mode 100644 index a9e12203..00000000 --- a/packages/mcp-server/src/tools/graphs/update-graphs.ts +++ /dev/null @@ -1,41 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; -import Writer from 'writer-sdk'; - -export const metadata: Metadata = { - resource: 'graphs', - operation: 'write', - tags: [], -}; - -export const tool: Tool = { - name: 'update_graphs', - description: 'Update the name and description of a Knowledge Graph.', - inputSchema: { - type: 'object', - properties: { - graph_id: { - type: 'string', - }, - description: { - type: 'string', - description: - 'A description of the Knowledge Graph (max 255 characters). Omitting this field leaves the description unchanged.', - }, - name: { - type: 'string', - description: - 'The name of the Knowledge Graph (max 255 characters). Omitting this field leaves the name unchanged.', - }, - }, - }, -}; - -export const handler = (client: Writer, args: any) => { - const { graph_id, ...body } = args; - return client.graphs.update(graph_id, body); -}; - -export default { metadata, tool, handler }; diff --git a/packages/mcp-server/src/tools/index.ts b/packages/mcp-server/src/tools/index.ts deleted file mode 100644 index 8f17a2ef..00000000 --- a/packages/mcp-server/src/tools/index.ts +++ /dev/null @@ -1,132 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -import Writer from 'writer-sdk'; -import { Tool } from '@modelcontextprotocol/sdk/types.js'; - -import retrieve_applications from './applications/retrieve-applications'; -import list_applications from './applications/list-applications'; -import generate_content_applications from './applications/generate-content-applications'; -import create_applications_jobs from './applications/jobs/create-applications-jobs'; -import retrieve_applications_jobs from './applications/jobs/retrieve-applications-jobs'; -import list_applications_jobs from './applications/jobs/list-applications-jobs'; -import retry_applications_jobs from './applications/jobs/retry-applications-jobs'; -import update_applications_graphs from './applications/graphs/update-applications-graphs'; -import list_applications_graphs from './applications/graphs/list-applications-graphs'; -import chat_chat from './chat/chat-chat'; -import create_completions from './completions/create-completions'; -import list_models from './models/list-models'; -import create_graphs from './graphs/create-graphs'; -import retrieve_graphs from './graphs/retrieve-graphs'; -import update_graphs from './graphs/update-graphs'; -import list_graphs from './graphs/list-graphs'; -import delete_graphs from './graphs/delete-graphs'; -import add_file_to_graph_graphs from './graphs/add-file-to-graph-graphs'; -import question_graphs from './graphs/question-graphs'; -import remove_file_from_graph_graphs from './graphs/remove-file-from-graph-graphs'; -import retrieve_files from './files/retrieve-files'; -import list_files from './files/list-files'; -import delete_files from './files/delete-files'; -import download_files from './files/download-files'; -import retry_files from './files/retry-files'; -import upload_files from './files/upload-files'; -import context_aware_splitting_tools from './tools/context-aware-splitting-tools'; -import parse_pdf_tools from './tools/parse-pdf-tools'; -import medical_tools_comprehend from './tools/comprehend/medical-tools-comprehend'; -import analyze_vision from './vision/analyze-vision'; - -export type HandlerFunction = (client: Writer, args: any) => Promise; - -export type Metadata = { - resource: string; - operation: 'read' | 'write'; - tags: string[]; -}; - -export type Endpoint = { - metadata: Metadata; - tool: Tool; - handler: HandlerFunction; -}; - -export const endpoints: Endpoint[] = []; - -function addEndpoint(endpoint: Endpoint) { - endpoints.push(endpoint); -} - -addEndpoint(retrieve_applications); -addEndpoint(list_applications); -addEndpoint(generate_content_applications); -addEndpoint(create_applications_jobs); -addEndpoint(retrieve_applications_jobs); -addEndpoint(list_applications_jobs); -addEndpoint(retry_applications_jobs); -addEndpoint(update_applications_graphs); -addEndpoint(list_applications_graphs); -addEndpoint(chat_chat); -addEndpoint(create_completions); -addEndpoint(list_models); -addEndpoint(create_graphs); -addEndpoint(retrieve_graphs); -addEndpoint(update_graphs); -addEndpoint(list_graphs); -addEndpoint(delete_graphs); -addEndpoint(add_file_to_graph_graphs); -addEndpoint(question_graphs); -addEndpoint(remove_file_from_graph_graphs); -addEndpoint(retrieve_files); -addEndpoint(list_files); -addEndpoint(delete_files); -addEndpoint(download_files); -addEndpoint(retry_files); -addEndpoint(upload_files); -addEndpoint(context_aware_splitting_tools); -addEndpoint(parse_pdf_tools); -addEndpoint(medical_tools_comprehend); -addEndpoint(analyze_vision); - -export type Filter = { - type: 'resource' | 'operation' | 'tag' | 'tool'; - op: 'include' | 'exclude'; - value: string; -}; - -export function query(filters: Filter[], endpoints: Endpoint[]): Endpoint[] { - if (filters.length === 0) { - return endpoints; - } - const allExcludes = filters.every((filter) => filter.op === 'exclude'); - - return endpoints.filter((endpoint: Endpoint) => { - let included = false || allExcludes; - - for (const filter of filters) { - if (match(filter, endpoint)) { - included = filter.op === 'include'; - } - } - - return included; - }); -} - -function match({ type, value }: Filter, endpoint: Endpoint): boolean { - switch (type) { - case 'resource': { - const regexStr = '^' + normalizeResource(value).replace(/\*/g, '.*') + '$'; - const regex = new RegExp(regexStr); - console.error('regex is', regexStr); - return regex.test(normalizeResource(endpoint.metadata.resource)); - } - case 'operation': - return endpoint.metadata.operation === value; - case 'tag': - return endpoint.metadata.tags.includes(value); - case 'tool': - return endpoint.tool.name === value; - } -} - -function normalizeResource(resource: string): string { - return resource.toLowerCase().replace(/[^a-z.*\-_]*/g, ''); -} diff --git a/packages/mcp-server/src/tools/models/list-models.ts b/packages/mcp-server/src/tools/models/list-models.ts deleted file mode 100644 index 11c4a8b5..00000000 --- a/packages/mcp-server/src/tools/models/list-models.ts +++ /dev/null @@ -1,27 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; -import Writer from 'writer-sdk'; - -export const metadata: Metadata = { - resource: 'models', - operation: 'read', - tags: [], -}; - -export const tool: Tool = { - name: 'list_models', - description: 'List models', - inputSchema: { - type: 'object', - properties: {}, - }, -}; - -export const handler = (client: Writer, args: any) => { - const {} = args; - return client.models.list(); -}; - -export default { metadata, tool, handler }; diff --git a/packages/mcp-server/src/tools/tools/comprehend/medical-tools-comprehend.ts b/packages/mcp-server/src/tools/tools/comprehend/medical-tools-comprehend.ts deleted file mode 100644 index 8727c1b7..00000000 --- a/packages/mcp-server/src/tools/tools/comprehend/medical-tools-comprehend.ts +++ /dev/null @@ -1,40 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../../'; -import Writer from 'writer-sdk'; - -export const metadata: Metadata = { - resource: 'tools.comprehend', - operation: 'write', - tags: [], -}; - -export const tool: Tool = { - name: 'medical_tools_comprehend', - description: - 'Analyze unstructured medical text to extract entities labeled with standardized medical codes and confidence scores.', - inputSchema: { - type: 'object', - properties: { - content: { - type: 'string', - description: 'The text to be analyzed.', - }, - response_type: { - type: 'string', - title: 'comprehend_medical_type', - description: - 'The structure of the response to be returned. `Entities` returns medical entities, `RxNorm` returns medication information, `ICD-10-CM` returns diagnosis codes, and `SNOMED CT` returns medical concepts.', - enum: ['Entities', 'RxNorm', 'ICD-10-CM', 'SNOMED CT'], - }, - }, - }, -}; - -export const handler = (client: Writer, args: any) => { - const { ...body } = args; - return client.tools.comprehend.medical(body); -}; - -export default { metadata, tool, handler }; diff --git a/packages/mcp-server/src/tools/tools/context-aware-splitting-tools.ts b/packages/mcp-server/src/tools/tools/context-aware-splitting-tools.ts deleted file mode 100644 index d794ffe5..00000000 --- a/packages/mcp-server/src/tools/tools/context-aware-splitting-tools.ts +++ /dev/null @@ -1,40 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; -import Writer from 'writer-sdk'; - -export const metadata: Metadata = { - resource: 'tools', - operation: 'write', - tags: [], -}; - -export const tool: Tool = { - name: 'context_aware_splitting_tools', - description: - 'Splits a long block of text (maximum 4000 words) into smaller chunks while preserving the semantic meaning of the text and context between the chunks.', - inputSchema: { - type: 'object', - properties: { - strategy: { - type: 'string', - title: 'splitting_strategy', - description: - 'The strategy to be used for splitting the text into chunks. `llm_split` uses the language model to split the text, `fast_split` uses a fast heuristic-based approach, and `hybrid_split` combines both strategies.', - enum: ['llm_split', 'fast_split', 'hybrid_split'], - }, - text: { - type: 'string', - description: 'The text to be split into chunks.', - }, - }, - }, -}; - -export const handler = (client: Writer, args: any) => { - const { ...body } = args; - return client.tools.contextAwareSplitting(body); -}; - -export default { metadata, tool, handler }; diff --git a/packages/mcp-server/src/tools/tools/parse-pdf-tools.ts b/packages/mcp-server/src/tools/tools/parse-pdf-tools.ts deleted file mode 100644 index e2dc6da8..00000000 --- a/packages/mcp-server/src/tools/tools/parse-pdf-tools.ts +++ /dev/null @@ -1,37 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; -import Writer from 'writer-sdk'; - -export const metadata: Metadata = { - resource: 'tools', - operation: 'write', - tags: [], -}; - -export const tool: Tool = { - name: 'parse_pdf_tools', - description: 'Parse PDF to other formats.', - inputSchema: { - type: 'object', - properties: { - file_id: { - type: 'string', - }, - format: { - type: 'string', - title: 'pdf_conversion_format', - description: 'The format into which the PDF content should be converted.', - enum: ['text', 'markdown'], - }, - }, - }, -}; - -export const handler = (client: Writer, args: any) => { - const { file_id, ...body } = args; - return client.tools.parsePdf(file_id, body); -}; - -export default { metadata, tool, handler }; diff --git a/packages/mcp-server/src/tools/vision/analyze-vision.ts b/packages/mcp-server/src/tools/vision/analyze-vision.ts deleted file mode 100644 index d859c7c7..00000000 --- a/packages/mcp-server/src/tools/vision/analyze-vision.ts +++ /dev/null @@ -1,59 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; -import Writer from 'writer-sdk'; - -export const metadata: Metadata = { - resource: 'vision', - operation: 'write', - tags: [], -}; - -export const tool: Tool = { - name: 'analyze_vision', - description: 'Submit images and a prompt to generate an analysis of the images.', - inputSchema: { - type: 'object', - properties: { - model: { - type: 'string', - description: 'The model to be used for image analysis. Currently only supports `palmyra-vision`.', - }, - prompt: { - type: 'string', - description: - 'The prompt to use for the image analysis. The prompt must include the name of each image variable, surrounded by double curly braces (`{{}}`). For example, `Describe the difference between the image {{image_1}} and the image {{image_2}}`.', - }, - variables: { - type: 'array', - items: { - type: 'object', - title: 'Vision Request File Variable', - description: - 'An array of file variables required for the analysis. The image files must be uploaded to the Writer platform before they can be used in a vision request. Learn how to upload files using the [Files API](/api-guides/api-reference/file-api/upload-files).', - properties: { - file_id: { - type: 'string', - description: - 'The File ID of the image to be analyzed. The file must be uploaded to the Writer platform before it can be used in a vision request.', - }, - name: { - type: 'string', - description: - 'The name of the file variable. You must reference this name in the prompt with double curly braces (`{{}}`). For example, `Describe the difference between the image {{image_1}} and the image {{image_2}}`.', - }, - }, - required: ['file_id', 'name'], - }, - }, - }, - }, -}; - -export const handler = (client: Writer, args: any) => { - const { ...body } = args; - return client.vision.analyze(body); -}; - -export default { metadata, tool, handler }; diff --git a/packages/mcp-server/tests/tools.test.ts b/packages/mcp-server/tests/tools.test.ts deleted file mode 100644 index 79979e3c..00000000 --- a/packages/mcp-server/tests/tools.test.ts +++ /dev/null @@ -1,226 +0,0 @@ -import { Endpoint, Filter, Metadata, query } from '../src/tools'; - -describe('Endpoint filtering', () => { - const endpoints: Endpoint[] = [ - endpoint({ - resource: 'user', - operation: 'read', - tags: ['admin'], - toolName: 'retrieve_user', - }), - endpoint({ - resource: 'user.profile', - operation: 'write', - tags: [], - toolName: 'create_user_profile', - }), - endpoint({ - resource: 'user.profile', - operation: 'read', - tags: [], - toolName: 'get_user_profile', - }), - endpoint({ - resource: 'user.roles.permissions', - operation: 'write', - tags: ['admin', 'security'], - toolName: 'update_user_role_permissions', - }), - endpoint({ - resource: 'documents.metadata.tags', - operation: 'write', - tags: ['taxonomy', 'metadata'], - toolName: 'create_document_metadata_tags', - }), - endpoint({ - resource: 'organization.settings', - operation: 'read', - tags: ['admin', 'configuration'], - toolName: 'get_organization_settings', - }), - ]; - - const tests: { name: string; filters: Filter[]; expected: string[] }[] = [ - { - name: 'match all', - filters: [], - expected: endpoints.map((e) => e.tool.name), - }, - - // Resource tests - { - name: 'simple resource', - filters: [{ type: 'resource', op: 'include', value: 'user' }], - expected: ['retrieve_user'], - }, - { - name: 'exclude resource', - filters: [{ type: 'resource', op: 'exclude', value: 'user' }], - expected: [ - 'create_user_profile', - 'get_user_profile', - 'update_user_role_permissions', - 'create_document_metadata_tags', - 'get_organization_settings', - ], - }, - { - name: 'resource and subresources', - filters: [{ type: 'resource', op: 'include', value: 'user*' }], - expected: ['retrieve_user', 'create_user_profile', 'get_user_profile', 'update_user_role_permissions'], - }, - { - name: 'just subresources', - filters: [{ type: 'resource', op: 'include', value: 'user.*' }], - expected: ['create_user_profile', 'get_user_profile', 'update_user_role_permissions'], - }, - { - name: 'specific subresource', - filters: [{ type: 'resource', op: 'include', value: 'user.roles.permissions' }], - expected: ['update_user_role_permissions'], - }, - { - name: 'deep wildcard match', - filters: [{ type: 'resource', op: 'include', value: '*.*.tags' }], - expected: ['create_document_metadata_tags'], - }, - - // Operation tests - { - name: 'read operation', - filters: [{ type: 'operation', op: 'include', value: 'read' }], - expected: ['retrieve_user', 'get_user_profile', 'get_organization_settings'], - }, - { - name: 'write operation', - filters: [{ type: 'operation', op: 'include', value: 'write' }], - expected: ['create_user_profile', 'update_user_role_permissions', 'create_document_metadata_tags'], - }, - { - name: 'resource and operation combined', - filters: [ - { type: 'resource', op: 'include', value: 'user.profile' }, - { type: 'operation', op: 'exclude', value: 'write' }, - ], - expected: ['get_user_profile'], - }, - - // Tag tests - { - name: 'admin tag', - filters: [{ type: 'tag', op: 'include', value: 'admin' }], - expected: ['retrieve_user', 'update_user_role_permissions', 'get_organization_settings'], - }, - { - name: 'taxonomy tag', - filters: [{ type: 'tag', op: 'include', value: 'taxonomy' }], - expected: ['create_document_metadata_tags'], - }, - { - name: 'multiple tags (OR logic)', - filters: [ - { type: 'tag', op: 'include', value: 'admin' }, - { type: 'tag', op: 'include', value: 'security' }, - ], - expected: ['retrieve_user', 'update_user_role_permissions', 'get_organization_settings'], - }, - { - name: 'excluding a tag', - filters: [ - { type: 'tag', op: 'include', value: 'admin' }, - { type: 'tag', op: 'exclude', value: 'security' }, - ], - expected: ['retrieve_user', 'get_organization_settings'], - }, - - // Tool name tests - { - name: 'tool name match', - filters: [{ type: 'tool', op: 'include', value: 'get_organization_settings' }], - expected: ['get_organization_settings'], - }, - { - name: 'two tools match', - filters: [ - { type: 'tool', op: 'include', value: 'get_organization_settings' }, - { type: 'tool', op: 'include', value: 'create_user_profile' }, - ], - expected: ['create_user_profile', 'get_organization_settings'], - }, - { - name: 'excluding tool by name', - filters: [ - { type: 'resource', op: 'include', value: 'user*' }, - { type: 'tool', op: 'exclude', value: 'retrieve_user' }, - ], - expected: ['create_user_profile', 'get_user_profile', 'update_user_role_permissions'], - }, - - // Complex combinations - { - name: 'complex filter: read operations with admin tag', - filters: [ - { type: 'operation', op: 'include', value: 'read' }, - { type: 'tag', op: 'include', value: 'admin' }, - ], - expected: [ - 'retrieve_user', - 'get_user_profile', - 'update_user_role_permissions', - 'get_organization_settings', - ], - }, - { - name: 'complex filter: user resources with no tags', - filters: [ - { type: 'resource', op: 'include', value: 'user.profile' }, - { type: 'tag', op: 'exclude', value: 'admin' }, - ], - expected: ['create_user_profile', 'get_user_profile'], - }, - { - name: 'complex filter: user resources and tags', - filters: [ - { type: 'resource', op: 'include', value: 'user.profile' }, - { type: 'tag', op: 'include', value: 'admin' }, - ], - expected: [ - 'retrieve_user', - 'create_user_profile', - 'get_user_profile', - 'update_user_role_permissions', - 'get_organization_settings', - ], - }, - ]; - - tests.forEach((test) => { - it(`filters by ${test.name}`, () => { - console.log(`Running test: ${test.name}`); - const filtered = query(test.filters, endpoints); - expect(filtered.map((e) => e.tool.name)).toEqual(test.expected); - }); - }); -}); - -function endpoint({ - resource, - operation, - tags, - toolName, -}: { - resource: string; - operation: Metadata['operation']; - tags: string[]; - toolName: string; -}): Endpoint { - return { - metadata: { - resource, - operation, - tags, - }, - tool: { name: toolName, inputSchema: { type: 'object', properties: {} } }, - handler: jest.fn(), - }; -} diff --git a/packages/mcp-server/tsc-multi.json b/packages/mcp-server/tsc-multi.json deleted file mode 100644 index 4facad5a..00000000 --- a/packages/mcp-server/tsc-multi.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "targets": [ - { "extname": ".js", "module": "commonjs" }, - { "extname": ".mjs", "module": "esnext" } - ], - "projects": ["tsconfig.build.json"] -} diff --git a/packages/mcp-server/tsconfig.build.json b/packages/mcp-server/tsconfig.build.json deleted file mode 100644 index c42fb8f8..00000000 --- a/packages/mcp-server/tsconfig.build.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "extends": "./tsconfig.json", - "include": ["dist/src"], - "exclude": [], - "compilerOptions": { - "rootDir": "./dist/src", - "paths": { - "writer-sdk-mcp/*": ["dist/src/*"], - "writer-sdk-mcp": ["dist/src/index.ts"] - }, - "noEmit": false, - "declaration": true, - "declarationMap": true, - "outDir": "dist", - "pretty": true, - "sourceMap": true - } -} diff --git a/packages/mcp-server/tsconfig.dist-src.json b/packages/mcp-server/tsconfig.dist-src.json deleted file mode 100644 index e9f2d70b..00000000 --- a/packages/mcp-server/tsconfig.dist-src.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - // this config is included in the published src directory to prevent TS errors - // from appearing when users go to source, and VSCode opens the source .ts file - // via declaration maps - "include": ["index.ts"], - "compilerOptions": { - "target": "es2015", - "lib": ["DOM"], - "moduleResolution": "node" - } -} diff --git a/packages/mcp-server/tsconfig.json b/packages/mcp-server/tsconfig.json deleted file mode 100644 index 8425e77e..00000000 --- a/packages/mcp-server/tsconfig.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "include": ["src", "tests", "examples"], - "exclude": [], - "compilerOptions": { - "target": "es2020", - "lib": ["es2020"], - "module": "commonjs", - "moduleResolution": "node", - "esModuleInterop": true, - "baseUrl": "./", - "paths": { - "writer-sdk-mcp/*": ["src/*"], - "writer-sdk-mcp": ["src/index.ts"] - }, - "noEmit": true, - - "resolveJsonModule": true, - - "forceConsistentCasingInFileNames": true, - - "strict": true, - "noImplicitAny": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "strictBindCallApply": true, - "strictPropertyInitialization": true, - "noImplicitThis": true, - "noImplicitReturns": true, - "alwaysStrict": true, - "exactOptionalPropertyTypes": true, - "noUncheckedIndexedAccess": true, - "noImplicitOverride": true, - "noPropertyAccessFromIndexSignature": true, - - "skipLibCheck": true - } -} diff --git a/release-please-config.json b/release-please-config.json index b1909804..624ed99e 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -62,12 +62,6 @@ "release-type": "node", "extra-files": [ "src/version.ts", - "README.md", - "packages/mcp-server/yarn.lock", - { - "type": "json", - "path": "packages/mcp-server/package.json", - "jsonpath": "$.version" - } + "README.md" ] } diff --git a/scripts/build-all b/scripts/build-all deleted file mode 100755 index 8ac03ea6..00000000 --- a/scripts/build-all +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash -set -exuo pipefail - -# build the core SDK package and all sub-packages - -bash ./scripts/build - -for dir in packages/*; do - if [ -d "$dir" ]; then - (cd "$dir" && yarn install && yarn build) - fi -done diff --git a/scripts/publish-packages.ts b/scripts/publish-packages.ts deleted file mode 100644 index 50e93fef..00000000 --- a/scripts/publish-packages.ts +++ /dev/null @@ -1,102 +0,0 @@ -/** - * Called from the `create-releases.yml` workflow with the output - * of the release please action as the first argument. - * - * Example JSON input: - * - * ```json - { - "releases_created": "true", - "release_created": "true", - "id": "137967744", - "name": "sdk: v0.14.5", - "tag_name": "sdk-v0.14.5", - "sha": "7cc2ba5c694e76a117f731d4cf0b06f8b8361f2e", - "body": "## 0.14.5 (2024-01-22)\n\n...", - "html_url": "https://github.com/$org/$repo/releases/tag/sdk-v0.14.5", - "draft": "false", - "upload_url": "https://uploads.github.com/repos/$org/$repo/releases/137967744/assets{?name,label}", - "path": ".", - "version": "0.14.5", - "major": "0", - "minor": "14", - "patch": "5", - "packages/additional-sdk--release_created": "true", - "packages/additional-sdk--id": "137967756", - "packages/additional-sdk--name": "additional-sdk: v0.5.2", - "packages/additional-sdk--tag_name": "additional-sdk-v0.5.2", - "packages/additional-sdk--sha": "7cc2ba5c694e76a117f731d4cf0b06f8b8361f2e", - "packages/additional-sdk--body": "## 0.5.2 (2024-01-22)\n\n...", - "packages/additional-sdk--html_url": "https://github.com/$org/$repo/releases/tag/additional-sdk-v0.5.2", - "packages/additional-sdk--draft": "false", - "packages/additional-sdk--upload_url": "https://uploads.github.com/repos/$org/$repo/releases/137967756/assets{?name,label}", - "packages/additional-sdk--path": "packages/additional-sdk", - "packages/additional-sdk--version": "0.5.2", - "packages/additional-sdk--major": "0", - "packages/additional-sdk--minor": "5", - "packages/additional-sdk--patch": "2", - "paths_released": "[\".\",\"packages/additional-sdk\"]" - } - ``` - */ - -import { execSync } from 'child_process'; -import path from 'path'; - -function main() { - const data = process.argv[2] ?? process.env['DATA']; - if (!data) { - throw new Error(`Usage: publish-packages.ts '{"json": "obj"}'`); - } - - const rootDir = path.join(__dirname, '..'); - console.log('root dir', rootDir); - console.log(`publish-packages called with ${data}`); - - const outputs = JSON.parse(data); - - const rawPaths = outputs.paths_released; - - if (!rawPaths) { - console.error(JSON.stringify(outputs, null, 2)); - throw new Error('Expected outputs to contain a truthy `paths_released` property'); - } - if (typeof rawPaths !== 'string') { - console.error(JSON.stringify(outputs, null, 2)); - throw new Error('Expected outputs `paths_released` property to be a JSON string'); - } - - const paths = JSON.parse(rawPaths); - if (!Array.isArray(paths)) { - console.error(JSON.stringify(outputs, null, 2)); - throw new Error('Expected outputs `paths_released` property to be an array'); - } - if (!paths.length) { - console.error(JSON.stringify(outputs, null, 2)); - throw new Error('Expected outputs `paths_released` property to contain at least one entry'); - } - - const publishScriptPath = path.join(rootDir, 'bin', 'publish-npm'); - console.log('Using publish script at', publishScriptPath); - - console.log('Ensuring root package is built'); - console.log(`$ yarn build`); - execSync(`yarn build`, { cwd: rootDir, encoding: 'utf8', stdio: 'inherit' }); - - for (const relPackagePath of paths) { - console.log('\n'); - - const packagePath = path.join(rootDir, relPackagePath); - console.log(`Publishing in directory: ${packagePath}`); - - console.log(`$ yarn install`); - execSync(`yarn install`, { cwd: packagePath, encoding: 'utf8', stdio: 'inherit' }); - - console.log(`$ bash ${publishScriptPath}`); - execSync(`bash ${publishScriptPath}`, { cwd: packagePath, encoding: 'utf8', stdio: 'inherit' }); - } - - console.log('Finished publishing packages'); -} - -main(); diff --git a/scripts/utils/make-dist-package-json.cjs b/scripts/utils/make-dist-package-json.cjs index 4d6634ea..7c24f56e 100644 --- a/scripts/utils/make-dist-package-json.cjs +++ b/scripts/utils/make-dist-package-json.cjs @@ -12,14 +12,6 @@ processExportMap(pkgJson.exports); for (const key of ['types', 'main', 'module']) { if (typeof pkgJson[key] === 'string') pkgJson[key] = pkgJson[key].replace(/^(\.\/)?dist\//, './'); } -// Fix bin paths if present -if (pkgJson.bin) { - for (const key in pkgJson.bin) { - if (typeof pkgJson.bin[key] === 'string') { - pkgJson.bin[key] = pkgJson.bin[key].replace(/^(\.\/)?dist\//, './'); - } - } -} delete pkgJson.devDependencies; delete pkgJson.scripts.prepack;