Spaces:
Sleeping
Sleeping
Jeremiah Lowin commited on
Commit ·
c431284
1
Parent(s): 8599822
Fix broken links
Browse filesFiles changed (5)
4 unmodified lines567891011111 unmodified lines1231241251261274 unmodified linesWelcome! This guide will help you quickly set up FastMCP and run your first MCP server.If you haven't already installed FastMCP, follow the [installation instructions](/docs/getting-started/installation).## Creating a FastMCP Server111 unmodified linesNote that FastMCP *does not* require the `__main__` block in the server file, and will ignore it if it is present. Instead, it looks for the server object provided in the CLI command (here, `mcp`). If no server object is provided, `fastmcp run` will automatically search for servers called "mcp", "app", or "server" in the file.<Tip>We pointed our client at the server file, which is recognized as a Python MCP server and executed with `python my_server.py` by default. This exceutes the `__main__` block of the server file. There are other ways to run the server, which are described in the [server configuration](/docs/getting-started/configuration) guide.</Tip>4 unmodified lines567891011111 unmodified lines1231241251261274 unmodified linesWelcome! This guide will help you quickly set up FastMCP and run your first MCP server.If you haven't already installed FastMCP, follow the [installation instructions](/getting-started/installation).## Creating a FastMCP Server111 unmodified linesNote that FastMCP *does not* require the `__main__` block in the server file, and will ignore it if it is present. Instead, it looks for the server object provided in the CLI command (here, `mcp`). If no server object is provided, `fastmcp run` will automatically search for servers called "mcp", "app", or "server" in the file.<Tip>We pointed our client at the server file, which is recognized as a Python MCP server and executed with `python my_server.py` by default. This exceutes the `__main__` block of the server file. There are other ways to run the server, which are described in the [server configuration](/servers/fastmcp#running-the-server) guide.</Tip>
4 unmodified lines567891011215 unmodified lines2272282292302312322334 unmodified linesicon: rectangle-code---When defining FastMCP [Tools](/server/tools), your functions might need to interact with the underlying MCP session or access server capabilities. FastMCP provides the `Context` object for this purpose.## What Is Context?215 unmodified linesreturn f"```python\n{code_example}\n```"```See [Client Sampling](/client/sampling) for more details on how clients handle these requests.### Request Information4 unmodified lines567891011215 unmodified lines2272282292302312322334 unmodified linesicon: rectangle-code---When defining FastMCP [tools](/servers/tools), your functions might need to interact with the underlying MCP session or access server capabilities. FastMCP provides the `Context` object for this purpose.## What Is Context?215 unmodified linesreturn f"```python\n{code_example}\n```"```See [Client Sampling](/clients/overview#llm-sampling) for more details on how clients handle these requests.### Request Information
27 unmodified lines28293031323334353610 unmodified lines474849505152536 unmodified lines606162636465667 unmodified lines747576777879807 unmodified lines8889909192939491 unmodified lines186187188189190191192193194104 unmodified lines29930030130227 unmodified lines* `name`: (Optional) A human-readable name for your server. Defaults to "FastMCP".* `instructions`: (Optional) Description of how to interact with this server. These instructions help clients understand the server's purpose and available functionality.* `lifespan`: (Optional) An async context manager function for server startup and shutdown logic. See [Lifespan Management](/advanced/lifespan).* `tags`: (Optional) A set of strings to tag the server itself.* `**settings`: Keyword arguments corresponding to `ServerSettings` for configuration. See [Configuration](/advanced/configuration).## Components10 unmodified linesreturn a * b```See [Tools](/server/tools) for detailed documentation.### Resources6 unmodified linesreturn {"theme": "dark", "version": "1.0"}```See [Resources & Templates](/server/resources) for detailed documentation.### Resource Templates7 unmodified linesreturn {"id": user_id, "name": f"User {user_id}", "status": "active"}```See [Resources & Templates](/server/resources) for detailed documentation.### Prompts7 unmodified linesreturn f"Please analyze these data points: {formatted_data}"```See [Prompts](/server/prompts) for detailed documentation.## Running the Server91 unmodified linesThe CLI can dynamically find and run FastMCP server objects in your files, but including the `if __name__ == "__main__":` block ensures compatibility with all clients.<Tip>For more options, including how to set up your server's dependencies or use advanced configurations, see the [CLI Reference](/cli/overview).</Tip>## Mounting Subservers104 unmodified linesAll of these can be configured directly as parameters when creating the `FastMCP` instance.See the [Configuration](/advanced/configuration) page for more details.27 unmodified lines28293031323334353610 unmodified lines474849505152536 unmodified lines606162636465667 unmodified lines747576777879807 unmodified lines8889909192939491 unmodified lines186187188189190191104 unmodified lines29629729827 unmodified lines* `name`: (Optional) A human-readable name for your server. Defaults to "FastMCP".* `instructions`: (Optional) Description of how to interact with this server. These instructions help clients understand the server's purpose and available functionality.* `lifespan`: (Optional) An async context manager function for server startup and shutdown logic.* `tags`: (Optional) A set of strings to tag the server itself.* `**settings`: Keyword arguments corresponding to additional `ServerSettings` configuration## Components10 unmodified linesreturn a * b```See [Tools](/servers/tools) for detailed documentation.### Resources6 unmodified linesreturn {"theme": "dark", "version": "1.0"}```See [Resources & Templates](/servers/resources) for detailed documentation.### Resource Templates7 unmodified linesreturn {"id": user_id, "name": f"User {user_id}", "status": "active"}```See [Resources & Templates](/servers/resources) for detailed documentation.### Prompts7 unmodified linesreturn f"Please analyze these data points: {formatted_data}"```See [Prompts](/servers/prompts) for detailed documentation.## Running the Server91 unmodified linesThe CLI can dynamically find and run FastMCP server objects in your files, but including the `if __name__ == "__main__":` block ensures compatibility with all clients.## Mounting Subservers104 unmodified linesAll of these can be configured directly as parameters when creating the `FastMCP` instance.
194 unmodified lines195196197198199200201194 unmodified lines- **LLM Sampling:** `ctx.sample(...)`- **Request Info:** `ctx.request_id`, `ctx.client_id`Refer to the [Using Context](/server/context) page for more details on these capabilities.## Server Behavior194 unmodified lines195196197198199200201194 unmodified lines- **LLM Sampling:** `ctx.sample(...)`- **Request Info:** `ctx.request_id`, `ctx.client_id`Refer to the [Context documentation](/servers/context) for more details on these capabilities.## Server Behavior
299 unmodified lines300301302303304305306299 unmodified lines- **LLM Sampling**: `ctx.sample(...)`- **Request Information**: `ctx.request_id`, `ctx.client_id`For full documentation on the Context object and all its capabilities, see the [Context Object](/server/context) page.## Server Behavior299 unmodified lines300301302303304305306299 unmodified lines- **LLM Sampling**: `ctx.sample(...)`- **Request Information**: `ctx.request_id`, `ctx.client_id`For full documentation on the Context object and all its capabilities, see the [Context documentation](/servers/context).## Server Behavior
docs/getting-started/quickstart.mdx+2-2
docs/servers/context.mdx+2-2
docs/servers/fastmcp.mdx+6-10
docs/servers/prompts.mdx+1-1
docs/servers/tools.mdx+1-1