> ## Documentation Index
> Fetch the complete documentation index at: https://fentaris.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# McpServer

> Reference for declaring upstream MCP servers.

> Declare upstream MCP servers for the Fentaris proxy

Use `mcp(...)` for new applications. It creates an `McpServer` wrapper around a transport and optionally configures display metadata, credentials, env injection, and isolation.

## Quick Start

```ts theme={null} theme={"theme":{"light":"github-light","dark":"github-dark"}}
import { mcp, stdio } from "@fentaris/core";

const filesystem = mcp("filesystem", {
  displayName: "Filesystem",
  transport: stdio({
    command: "npx",
    args: ["-y", "@modelcontextprotocol/server-filesystem", "./demo-files"],
  }),
});
```

## Options

### `name`

Server identifier. It becomes the prefix for proxied tool names.

<Note>
  Server names must be stable and must not include `__`.
</Note>

### `displayName`

Human-readable label used in tool titles.

### `transport`

Transport implementation used to connect to the upstream MCP server.

```ts theme={null} theme={"theme":{"light":"github-light","dark":"github-dark"}}
transport: stdio({
  command: "npx",
  args: ["-y", "@modelcontextprotocol/server-filesystem", "./demo-files"],
})
```

### `env`

Static env map or resolver function by user.

```ts theme={null} theme={"theme":{"light":"github-light","dark":"github-dark"}}
env: (user) => ({
  USER_ID: user.id ?? "anonymous",
})
```

### `auth`

Credential binding used when the server needs bearer or header auth.

### `isolation`

Optional isolation runtime for user-aware queueing or process isolation.

## Methods

### `listTools(params?, user?)`

Lists tools for the given user.

### `callTool(params, user?)`

Calls a tool for the given user.

### `listResources(params?, user?)`

Lists resources for the given user. Returns an empty `resources` array when the underlying transport does not implement resource listing.

### `readResource(params, user?)`

Reads a resource for the given user. Throws when the underlying transport does not implement resource reading.

### `listResourceTemplates(params?, user?)`

Lists resource templates for the given user. Returns an empty `resourceTemplates` array when unsupported.

### `listPrompts(params?, user?)`

Lists prompts for the given user. Returns an empty `prompts` array when unsupported.

### `getPrompt(params, user?)`

Gets a prompt for the given user. Throws when unsupported.

### `complete(params, user?)`

Forwards MCP argument completion for prompt and resource references. Throws when unsupported.

### `supportsResources()`, `supportsPrompts()`, `supportsCompletions()`

Returns whether the configured transport exposes the corresponding optional methods. `McpProxy` uses these checks to advertise downstream capabilities.

### `close()`

Closes all transports, including user-specific ones.

## Low-Level Constructor

The class constructor is available for advanced integrations:

```ts theme={null} theme={"theme":{"light":"github-light","dark":"github-dark"}}
import { McpServer } from "@fentaris/core";

const server = new McpServer({
  name: "filesystem",
  transport,
});
```

For normal applications, prefer `mcp(name, options)`.

## Related Documentation

* [McpProxy reference](/reference/mcp-proxy)
* [Stdio transport](/reference/stdio-transport)
* [Servers and transports](/concepts/servers-and-transports)
