npm package: @globusgroup/watchman-mcp
Description: The official MCP Server for the Watchman API
Author: Watchman
Latest version: 0.1.0-alpha.4

# Watchman 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 WATCHMAN_API_KEY="My API Key"
npx -y @globusgroup/watchman-mcp@latest
```

### 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": {
    "globusgroup_watchman_api": {
      "command": "npx",
      "args": ["-y", "@globusgroup/watchman-mcp", "--client=claude", "--tools=dynamic"],
      "env": {
        "WATCHMAN_API_KEY": "My API Key"
      }
    }
  }
}
```

## Exposing endpoints to your MCP Client

There are two ways to expose endpoints as tools in the MCP server:

1. Exposing one tool per endpoint, and filtering as necessary
2. Exposing a set of tools to dynamically discover and invoke endpoints from the API

### Filtering endpoints and 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

### Dynamic tools

If you specify `--tools=dynamic` to the MCP server, instead of exposing one tool per endpoint in the API, it will
expose the following tools:

1. `list_api_endpoints` - Discovers available endpoints, with optional filtering by search query
2. `get_api_endpoint_schema` - Gets detailed schema information for a specific endpoint
3. `invoke_api_endpoint` - Executes any endpoint with the appropriate parameters

This allows you to have the full set of API endpoints available to your MCP Client, while not requiring that all
of their schemas be loaded into context at once. Instead, the LLM will automatically use these tools together to
search for, look up, and invoke endpoints dynamically. However, due to the indirect nature of the schemas, it
can struggle to provide the correct properties a bit more than when tools are imported explicitly. Therefore,
you can opt-in to explicit tools, the dynamic tools, or both.

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.

### Specifying the MCP Client

Different clients have varying abilities to handle arbitrary tools and schemas.

You can specify the client you are using with the `--client` argument, and the MCP server will automatically
serve tools and schemas that are more compatible with that client.

- `--client=<type>`: Set all capabilities based on a known MCP client

  - Valid values: `openai-agents`, `claude`, `claude-code`, `cursor`
  - Example: `--client=cursor`

Additionally, if you have a client not on the above list, or the client has gotten better
over time, you can manually enable or disable certain capabilities:

- `--capability=<name>`: Specify individual client capabilities
  - Available capabilities:
    - `top-level-unions`: Enable support for top-level unions in tool schemas
    - `valid-json`: Enable JSON string parsing for arguments
    - `refs`: Enable support for $ref pointers in schemas
    - `unions`: Enable support for union types (anyOf) in schemas
    - `formats`: Enable support for format validations in schemas (e.g. date-time, email)
    - `tool-name-length=N`: Set maximum tool name length to N characters
  - Example: `--capability=top-level-unions --capability=tool-name-length=40`
  - Example: `--capability=top-level-unions,tool-name-length=40`

### Examples

1. Filter for read operations on cards:

```bash
--resource=cards --operation=read
```

2. Exclude specific tools while including others:

```bash
--resource=cards --no-tool=create_cards
```

3. Configure for Cursor client with custom max tool name length:

```bash
--client=cursor --capability=tool-name-length=40
```

4. Complex filtering with multiple criteria:

```bash
--resource=cards,accounts --operation=read --tag=kyc --no-tool=create_cards
```

## Importing the tools and server individually

```js
// Import the server, generated endpoints, or the init function
import { server, endpoints, init } from "@globusgroup/watchman-mcp/server";

// import a specific tool
import createBodies from "@globusgroup/watchman-mcp/tools/bodies/create-bodies";

// 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: [createBodies, myCustomEndpoint] });
```

## Available Tools

The following tools are available in this MCP server.

### Resource `bodies`:

- `create_bodies` (`write`): Creates a new body in the database.
- `retrieve_bodies` (`read`): Returns a body by its ID.
- `update_bodies` (`write`): Updates a body by its ID.
- `list_bodies` (`read`): Returns all bodies in the database.
- `delete_bodies` (`write`): Deletes a body by its ID.

### Resource `comments`:

- `create_comments` (`write`): Creates a new comment in the database.
- `retrieve_comments` (`read`): Returns a comment by its ID.
- `update_comments` (`write`): Updates a comment by its ID.
- `list_comments` (`read`): Returns all comments or filtered comments based on the provided parameters.
- `delete_comments` (`write`): Deletes a comment by its ID.

### Resource `contacts`:

- `create_contacts` (`write`): Creates a new contact in the database and associates it with the specified contactable entity.
- `retrieve_contacts` (`read`): Returns a contact by its ID.
- `update_contacts` (`write`): Updates a contact by its ID.
- `list_contacts` (`read`): Returns all contacts in the database, optionally filtered by contactable type and ID.
- `delete_contacts` (`write`): Deletes a contact by its ID.

### Resource `document_types`:

- `create_document_types` (`write`): Creates a new document type in the database.
- `retrieve_document_types` (`read`): Returns a document type by its ID.
- `update_document_types` (`write`): Updates a document type by its ID.
- `delete_document_types` (`write`): Deletes a document type by its ID.
- `accept_invite_document_types` (`write`): Accepts pending document type access invites by providing the temporary code and user password.
  Creates or updates private keys for the granted document types.
- `get_my_access_document_types` (`read`): Returns document types that the authenticated user has permission to grant access to other users.
  For high sensitivity document types, the user must have the private key.
- `grant_access_document_types` (`write`): Grants access to document types for a specified user. For high sensitivity document types,
  creates encrypted invites that require the user's password to accept.
- `list_all_document_types` (`read`): Returns all document types in the database.
- `list_pending_invites_document_types` (`read`): Returns all pending document type access invites for the authenticated user,
  grouped by invite group with document type details.
- `list_user_access_document_types` (`read`): Returns a comprehensive list of all users and their assigned document types,
  including user roles and document type sensitivity levels.
- `revoke_access_document_types` (`write`): Removes access to specified document types for a user. The authenticated user must have
  permission to revoke access to the specified document types.

### Resource `document_types.notification_strategies`:

- `list_document_types_notification_strategies` (`read`): Returns the notification strategies assigned to a document type.
- `sync_document_types_notification_strategies` (`write`): Assigns notification strategies to a document type.

### Resource `documents`:

- `create_documents` (`write`): Create a new document
- `retrieve_documents` (`read`): Display the specified document
- `list_documents` (`read`): Get all documents
- `download_documents` (`read`): Download the specified document

### Resource `factories`:

- `retrieve_factories` (`read`): Get a factory
- `update_factories` (`write`): Update a factory
- `list_factories` (`read`): Get all factories

### Resource `notification_strategies`:

- `create_notification_strategies` (`write`): Create a new notification strategy
- `retrieve_notification_strategies` (`read`): Get a notification strategy
- `update_notification_strategies` (`write`): Update a notification strategy
- `list_notification_strategies` (`read`): Get all notification strategies
- `delete_notification_strategies` (`write`): Delete a notification strategy

### Resource `notification_strategy_alerts`:

- `create_notification_strategy_alerts` (`write`): Create a new notification strategy alert
- `retrieve_notification_strategy_alerts` (`read`): Get a notification strategy alert
- `update_notification_strategy_alerts` (`write`): Update a notification strategy alert
- `list_notification_strategy_alerts` (`read`): Get all notification strategy alerts
- `delete_notification_strategy_alerts` (`write`): Delete a notification strategy alert

### Resource `categories`:

- `list_categories` (`read`): Get product categories

### Resource `users`:

- `create_users` (`write`): Create a new user
- `retrieve_users` (`read`): Get a user
- `update_users` (`write`): Update a user
- `list_users` (`read`): Get all users
- `ban_users` (`write`): Ban a user (soft delete)
- `change_password_users` (`write`): Changes the password for the authenticated user.
- `reset_password_users` (`write`): Resets the password for the authenticated user when they have lost their password.
- `retrieve_all_permissions_users` (`read`): Returns all permissions available to the specified user, including both
  direct permissions and permissions inherited through assigned roles.
- `retrieve_me_users` (`read`): Get authenticated user
- `set_password_users` (`write`): Set initial password for authenticated user

### Resource `users.categories`:

- `retrieve_users_categories` (`read`): Get product categories assigned to a user
- `assign_users_categories` (`write`): Assign product categories to a user (add without removing existing relationshipts)
- `remove_users_categories` (`write`): Remove a product category assignment from a user
- `sync_users_categories` (`write`): Sync product categories to a user (replace existing relationshipts)

### Resource `users.permissions`:

- `retrieve_users_permissions` (`read`): Returns all direct permissions currently assigned to the specified user.
  Note: This only returns direct permissions, not permissions inherited through roles.
- `sync_users_permissions` (`write`): Replaces all current direct permission assignments for the specified user with the provided permissions.
  This operation will remove any existing direct permissions not included in the request.
  Note: This only affects direct permissions, not permissions inherited through roles.

### Resource `users.roles`:

- `retrieve_users_roles` (`read`): Returns all roles currently assigned to the specified user.
- `sync_users_roles` (`write`): Replaces all current role assignments for the specified user with the provided roles.
  This operation will remove any existing roles not included in the request.

### Resource `recovery_mode`:

- `finalise_recovery_mode` (`write`): This method finalises the recovery mode by re-encrypting the private keys using the new password and storing them in the database.
- `initialise_recovery_mode` (`write`): This method initialises the recovery mode by encrypting the provided recovery private key and storing it in the session.

### Resource `suppliers`:

- `create_suppliers` (`write`): Create a new supplier
- `retrieve_suppliers` (`read`): Get a supplier
- `update_suppliers` (`write`): Update a supplier
- `list_suppliers` (`read`): Get all suppliers
- `delete_suppliers` (`write`): Delete a supplier

### Resource `notifications_teams_channels`:

- `create_notifications_teams_channels` (`write`): Creates a new Microsoft Teams channel configuration for sending notifications.
- `retrieve_notifications_teams_channels` (`read`): Returns details of a specific Microsoft Teams channel configuration.
- `update_notifications_teams_channels` (`write`): Updates the configuration of an existing Microsoft Teams channel.
- `list_notifications_teams_channels` (`read`): Returns a list of all Microsoft Teams channels configured for notifications.
- `delete_notifications_teams_channels` (`write`): Removes a Microsoft Teams channel configuration from the system.

### Resource `audit_logs`:

- `retrieve_audit_logs` (`read`): Returns a specific audit log by its ID.
- `list_audit_logs` (`read`): Returns all audit logs in the database, ordered by most recent first.

### Resource `search`:

- `retrieve_search` (`read`):

### Resource `permissions`:

- `list_permissions` (`read`): Returns all permissions available in the system. This is useful for building
  user interfaces that need to display available permissions for assignment.

### Resource `roles`:

- `list_roles` (`read`): Returns all roles available in the system. This is useful for building
  user interfaces that need to display available roles for assignment.

### Resource `notifications`:

- `list_notifications` (`read`): Returns a paginated list of the current user's notifications, optionally filtered by read status.
- `get_unread_count_notifications` (`read`): Returns the count of unread notifications for the current user.
- `mark_all_read_notifications` (`write`): Marks all unread notifications as read for the current user.
- `mark_read_notifications` (`write`): Marks a specific notification as read for the current user.