mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-22 13:34:17 +02:00
Merge branch 'main' into custom-tags
This commit is contained in:
commit
ef8bb6f631
13 changed files with 129 additions and 19 deletions
|
|
@ -91,7 +91,7 @@ For more control over connection details (like headers for SSE, environment vari
|
|||
|
||||
### Multi-Server Clients
|
||||
|
||||
<VersionBadge version="2.3.6" />
|
||||
<VersionBadge version="2.4.0" />
|
||||
|
||||
FastMCP supports creating clients that connect to multiple MCP servers through a single client interface using a standard MCP configuration format (`MCPConfig`). This configuration approach makes it easy to connect to multiple specialized servers or create composable systems with a simple, declarative syntax.
|
||||
|
||||
|
|
|
|||
|
|
@ -323,7 +323,7 @@ Communication happens through efficient in-memory queues, making it very fast an
|
|||
|
||||
### MCPConfig Transport
|
||||
|
||||
<VersionBadge version="2.3.6" />
|
||||
<VersionBadge version="2.4.0" />
|
||||
|
||||
- **Class:** `fastmcp.client.transports.MCPConfigTransport`
|
||||
- **Inferred From:** An instance of `MCPConfig` or a dictionary matching the MCPConfig schema
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ The choice of importing or mounting depends on your use case and requirements.
|
|||
|
||||
FastMCP supports [MCP proxying](/patterns/proxy), which allows you to mirror a local or remote server in a local FastMCP instance. Proxies are fully compatible with both importing and mounting.
|
||||
|
||||
<VersionBadge version="2.3.6" />
|
||||
<VersionBadge version="2.4.0" />
|
||||
|
||||
You can also create proxies from configuration dictionaries that follow the MCPConfig schema, which is useful for quickly connecting to one or more remote servers. See the [Proxy Servers documentation](/servers/proxy#configuration-based-proxies) for details on configuration-based proxying. Note that MCPConfig follows an emerging standard and its format may evolve over time.
|
||||
|
||||
|
|
|
|||
|
|
@ -228,8 +228,8 @@ async def analyze_sentiment(text: str, ctx: Context) -> dict:
|
|||
# Create a sampling prompt asking for sentiment analysis
|
||||
prompt = f"Analyze the sentiment of the following text as positive, negative, or neutral. Just output a single word - 'positive', 'negative', or 'neutral'. Text to analyze: {text}"
|
||||
|
||||
# Send the sampling request to the client's LLM
|
||||
response = await ctx.sample(prompt)
|
||||
# Send the sampling request to the client's LLM (provide a hint for the model you want to use)
|
||||
response = await ctx.sample(prompt, model_preferences="claude-3-sonnet")
|
||||
|
||||
# Process the LLM's response
|
||||
sentiment = response.text.strip().lower()
|
||||
|
|
@ -247,11 +247,12 @@ async def analyze_sentiment(text: str, ctx: Context) -> dict:
|
|||
|
||||
**Method signature:**
|
||||
|
||||
- **`ctx.sample(messages: str | list[str | SamplingMessage], system_prompt: str | None = None, temperature: float | None = None, max_tokens: int | None = None) -> TextContent | ImageContent`**
|
||||
- **`ctx.sample(messages: str | list[str | SamplingMessage], system_prompt: str | None = None, temperature: float | None = None, max_tokens: int | None = None, model_preferences: ModelPreferences | str | list[str] | None = None) -> TextContent | ImageContent`**
|
||||
- `messages`: A string or list of strings/message objects to send to the LLM
|
||||
- `system_prompt`: Optional system prompt to guide the LLM's behavior
|
||||
- `temperature`: Optional sampling temperature (controls randomness)
|
||||
- `max_tokens`: Optional maximum number of tokens to generate (defaults to 512)
|
||||
- `model_preferences`: Optional model selection preferences (e.g., a model hint string, list of hints, or a ModelPreferences object)
|
||||
- Returns the LLM's response as TextContent or ImageContent
|
||||
|
||||
When providing a simple string, it's treated as a user message. For more complex scenarios, you can provide a list of messages with different roles.
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ proxy = FastMCP.as_proxy(
|
|||
|
||||
### Configuration-Based Proxies
|
||||
|
||||
<VersionBadge version="2.3.6" />
|
||||
<VersionBadge version="2.4.0" />
|
||||
|
||||
You can create a proxy directly from a configuration dictionary that follows the MCPConfig schema. This is useful for quickly setting up proxies to remote servers without manually configuring each connection detail.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue