mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-23 22:14:18 +02:00
chore: Update SDK documentation (#2604)
Co-authored-by: marvin-context-protocol[bot] <225465937+marvin-context-protocol[bot]@users.noreply.github.com>
This commit is contained in:
parent
ae3c2abbf6
commit
9d5ffa86b3
55 changed files with 3213 additions and 1480 deletions
34
docs/python-sdk/fastmcp-server-providers-__init__.mdx
Normal file
34
docs/python-sdk/fastmcp-server-providers-__init__.mdx
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
---
|
||||
title: __init__
|
||||
sidebarTitle: __init__
|
||||
---
|
||||
|
||||
# `fastmcp.server.providers`
|
||||
|
||||
|
||||
Providers for dynamic MCP components.
|
||||
|
||||
This module provides the `Provider` abstraction for providing tools,
|
||||
resources, and prompts dynamically at runtime.
|
||||
|
||||
Example:
|
||||
```python
|
||||
from fastmcp import FastMCP
|
||||
from fastmcp.server.providers import Provider
|
||||
from fastmcp.tools import Tool
|
||||
|
||||
class DatabaseProvider(Provider):
|
||||
def __init__(self, db_url: str):
|
||||
self.db = Database(db_url)
|
||||
|
||||
async def list_tools(self) -> list[Tool]:
|
||||
rows = await self.db.fetch("SELECT * FROM tools")
|
||||
return [self._make_tool(row) for row in rows]
|
||||
|
||||
async def get_tool(self, name: str) -> Tool | None:
|
||||
row = await self.db.fetchone("SELECT * FROM tools WHERE name = ?", name)
|
||||
return self._make_tool(row) if row else None
|
||||
|
||||
mcp = FastMCP("Server", providers=[DatabaseProvider(db_url)])
|
||||
```
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue