Add client docs

This commit is contained in:
Jeremiah Lowin 2025-07-28 17:49:32 -04:00
commit 6b8a62c127
3 changed files with 78 additions and 0 deletions

View file

@ -25,8 +25,33 @@ async with client:
print(f"Description: {prompt.description}")
if prompt.arguments:
print(f"Arguments: {[arg.name for arg in prompt.arguments]}")
# Access tags and other metadata
if hasattr(prompt, '_meta') and prompt._meta:
print(f"Tags: {prompt._meta.get('tags', [])}")
```
### Filtering by Tags
You can use the `meta` field to filter prompts based on their tags:
```python
async with client:
prompts = await client.list_prompts()
# Filter prompts by tag
analysis_prompts = [
prompt for prompt in prompts
if hasattr(prompt, '_meta') and prompt._meta and
'analysis' in prompt._meta.get('tags', [])
]
print(f"Found {len(analysis_prompts)} analysis prompts")
```
<Note>
The `_meta` field is part of the standard MCP specification, but the inclusion of tags within it is specific to FastMCP servers. Other MCP server implementations may not provide tags in their metadata.
</Note>
## Using Prompts
### Basic Usage

View file

@ -34,6 +34,9 @@ async with client:
print(f"Name: {resource.name}")
print(f"Description: {resource.description}")
print(f"MIME Type: {resource.mimeType}")
# Access tags and other metadata
if hasattr(resource, '_meta') and resource._meta:
print(f"Tags: {resource._meta.get('tags', [])}")
```
### Resource Templates
@ -49,8 +52,33 @@ async with client:
print(f"Template URI: {template.uriTemplate}")
print(f"Name: {template.name}")
print(f"Description: {template.description}")
# Access tags and other metadata
if hasattr(template, '_meta') and template._meta:
print(f"Tags: {template._meta.get('tags', [])}")
```
### Filtering by Tags
You can use the `meta` field to filter resources based on their tags:
```python
async with client:
resources = await client.list_resources()
# Filter resources by tag
config_resources = [
resource for resource in resources
if hasattr(resource, '_meta') and resource._meta and
'config' in resource._meta.get('tags', [])
]
print(f"Found {len(config_resources)} config resources")
```
<Note>
The `_meta` field is part of the standard MCP specification, but the inclusion of tags within it is specific to FastMCP servers. Other MCP server implementations may not provide tags in their metadata.
</Note>
## Reading Resources
### Static Resources

View file

@ -25,8 +25,33 @@ async with client:
print(f"Description: {tool.description}")
if tool.inputSchema:
print(f"Parameters: {tool.inputSchema}")
# Access tags and other metadata
if hasattr(tool, '_meta') and tool._meta:
print(f"Tags: {tool._meta.get('tags', [])}")
```
### Filtering by Tags
You can use the `meta` field to filter tools based on their tags:
```python
async with client:
tools = await client.list_tools()
# Filter tools by tag
analysis_tools = [
tool for tool in tools
if hasattr(tool, '_meta') and tool._meta and
'analysis' in tool._meta.get('tags', [])
]
print(f"Found {len(analysis_tools)} analysis tools")
```
<Note>
The `_meta` field is part of the standard MCP specification, but the inclusion of tags within it is specific to FastMCP servers. Other MCP server implementations may not provide tags in their metadata.
</Note>
## Executing Tools
### Basic Execution