Skip to content

Commit 51813fa

Browse files
committed
feat: document Pararam message formatting
1 parent e0ad7cf commit 51813fa

7 files changed

Lines changed: 190 additions & 1 deletion

File tree

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,14 @@ Send a message to a chat with optional reply and quote functionality.
6262
- `reply_to_message_id` (optional): Post number to reply to
6363
- `quote_text` (optional): Text to quote from the replied message (only used with `reply_to_message_id`)
6464

65+
**Message formatting:**
66+
Pararam supports Markdown-like text, but does not support Markdown headings (`#`, `##`, `###`).
67+
Use `**bold**` section titles instead. Use colors as `[#RRGGBB](text)`;
68+
colored bullet example: `[#2E7D32](●)`. Keep tables simple because colors may not render inside
69+
table cells. Use `@all`, `@online`, `@admin`, and `@groups` only when the user explicitly asks
70+
for broad notification, and ask for explicit confirmation before sending such mentions.
71+
See [docs/PARARAM_FORMATTING.md](docs/PARARAM_FORMATTING.md) for the full syntax.
72+
6573
**Examples:**
6674
```python
6775
# Simple message

docs/PARARAM_FORMATTING.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Pararam Message Formatting Reference
2+
3+
Use this reference when composing text for `send_message` or `edit_post`.
4+
5+
## Core Rules For Agents
6+
7+
- Do not use Markdown headings (`#`, `##`, `###`). Pararam does not support them.
8+
- Use `**bold**` section titles instead of headings.
9+
- Prefer plain bullets or numbered lists for structure.
10+
- Keep tool descriptions concise; use the `pararam://formatting` MCP resource only when the task needs details.
11+
12+
## Mentions
13+
14+
- `@user` mentions a user.
15+
- `@@role` mentions a role.
16+
- `@all` mentions all users in the chat.
17+
- `@online` mentions online users.
18+
- `@admin` mentions all admins.
19+
- `@groups` mentions all roles.
20+
21+
Use `@all`, `@online`, `@admin`, and `@groups` only when the user explicitly asks to notify everyone,
22+
online users, chat admins, or groups/roles. Prefer targeted user or role mentions otherwise.
23+
Before sending any message with `@all`, `@online`, `@admin`, or `@groups`, ask the user for explicit confirmation.
24+
25+
## Hashtags And Alerts
26+
27+
- `#example` creates a hashtag.
28+
- `#eta` creates a reminder.
29+
- `#shareedit` enables collaborative editing for the post.
30+
- `#snd_call`, `#snd_ok`, `#snd_fail`, and `#snd_silent` choose the notification sound.
31+
32+
## Links, Tooltips, And Colors
33+
34+
- Markdown-style link: `[label](https://example.com)`.
35+
- Tooltip: `[visible text](tooltip text)`.
36+
- Colored text: `[#RRGGBB](text)` or `[#red](text)`.
37+
- Colored bullet: `[#2E7D32](●)`.
38+
- Phone link: `[#tel](+7 952 67 47 180)`.
39+
40+
## Quotes, Code, And Inline Code
41+
42+
- One-line quote: `> quoted text`.
43+
- Inline code or inline monospace: `` `text` ``.
44+
- Multiline block or code fence: start a separate line with three backticks.
45+
- For syntax highlighting, use a language after the opening backticks, for example ` ```python `.
46+
47+
## Tables
48+
49+
Tables are supported with Markdown table syntax. Keep them simple.
50+
Colors may not render inside table cells, so do not rely on colored markers in tables.
51+
52+
## Checkboxes And Spoilers
53+
54+
- Empty checkbox: `[ ](task text)`.
55+
- Checked checkbox: `[x](task text)`.
56+
- Spoiler: `[#spoiler](hidden text)`.
57+
58+
## Attach Long Text
59+
60+
To send text as an attachment, start a line with `/paste filename`.

docs/TOOLS.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,14 @@ Send a message to a chat.
131131
- `text` (str): Message text to send
132132
- `reply_to_message_id` (str, optional): Post number to reply to
133133

134+
**Message Formatting:**
135+
Pararam supports Markdown-like text, but does not support Markdown headings (`#`, `##`, `###`).
136+
Use `**bold**` section titles instead. Use colors as `[#RRGGBB](text)`;
137+
colored bullet example: `[#2E7D32](●)`. Keep tables simple because colors may not render inside
138+
table cells. Use `@all`, `@online`, `@admin`, and `@groups` only when the user explicitly asks
139+
for broad notification, and ask for explicit confirmation before sending such mentions.
140+
See `docs/PARARAM_FORMATTING.md` for the full syntax.
141+
134142
**Returns:**
135143
`ToolResponse[SendMessagePayload]` with payload containing:
136144
- `post_no`: ID of the sent message
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
"""Pararam message formatting guidance exposed to MCP clients."""
2+
3+
PARARAM_FORMATTING_GUIDE = """Pararam message formatting:
4+
- Do not use Markdown headings (#, ##, ###); Pararam does not support them.
5+
- Use **bold** section titles, bullets, numbered lists, blockquotes (>), inline code, and code fences.
6+
- Use colors as [#RRGGBB](text); colored bullet example: [#2E7D32](●).
7+
- Keep tables simple; colors may not render inside table cells.
8+
- Use @all, @online, @admin, and @groups only when the user explicitly asks to notify everyone,
9+
online users, chat admins, or groups/roles.
10+
- Before sending a message with @all, @online, @admin, or @groups, ask the user for explicit confirmation.
11+
- For full syntax details, read the pararam://formatting resource.
12+
"""
13+
14+
PARARAM_FORMATTING_REFERENCE = """# Pararam Message Formatting Reference
15+
16+
Use this reference when composing text for send_message or edit_post.
17+
18+
## Core Rules For Agents
19+
20+
- Do not use Markdown headings (#, ##, ###). Pararam does not support them.
21+
- Use **bold** section titles instead of headings.
22+
- Prefer plain bullets or numbered lists for structure.
23+
- Keep tool descriptions concise; use this reference only when the task needs formatting details.
24+
25+
## Mentions
26+
27+
- @user mentions a user.
28+
- @@role mentions a role.
29+
- @all mentions all users in the chat.
30+
- @online mentions online users.
31+
- @admin mentions all admins.
32+
- @groups mentions all roles.
33+
34+
Use @all, @online, @admin, and @groups only when the user explicitly asks to notify everyone,
35+
online users, chat admins, or groups/roles. Prefer targeted user or role mentions otherwise.
36+
Before sending any message with @all, @online, @admin, or @groups, ask the user for explicit confirmation.
37+
38+
## Hashtags And Alerts
39+
40+
- #example creates a hashtag.
41+
- #eta creates a reminder.
42+
- #shareedit enables collaborative editing for the post.
43+
- #snd_call, #snd_ok, #snd_fail, and #snd_silent choose the notification sound.
44+
45+
## Links, Tooltips, And Colors
46+
47+
- Markdown-style link: [label](https://example.com).
48+
- Tooltip: [visible text](tooltip text).
49+
- Colored text: [#RRGGBB](text) or [#red](text).
50+
- Colored bullet: [#2E7D32](●).
51+
- Phone link: [#tel](+7 952 67 47 180).
52+
53+
## Quotes, Code, And Inline Code
54+
55+
- One-line quote: > quoted text.
56+
- Inline code or inline monospace: `text`.
57+
- Multiline block or code fence: start a separate line with three backticks.
58+
- For syntax highlighting, use a language after the opening backticks, for example ```python.
59+
60+
## Tables
61+
62+
Tables are supported with Markdown table syntax. Keep them simple.
63+
Colors may not render inside table cells, so do not rely on colored markers in tables.
64+
65+
## Checkboxes And Spoilers
66+
67+
- Empty checkbox: [ ](task text).
68+
- Checked checkbox: [x](task text).
69+
- Spoiler: [#spoiler](hidden text).
70+
71+
## Attach Long Text
72+
73+
To send text as an attachment, start a line with /paste filename.
74+
"""

packages/pararam-nexus-mcp/src/pararam_nexus_mcp/server.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from fastmcp import FastMCP
1212

1313
from pararam_nexus_mcp.config import config
14+
from pararam_nexus_mcp.formatting import PARARAM_FORMATTING_GUIDE, PARARAM_FORMATTING_REFERENCE
1415
from pararam_nexus_mcp.tools.chats import register_chat_tools
1516
from pararam_nexus_mcp.tools.posts import register_post_tools
1617
from pararam_nexus_mcp.tools.users import register_user_tools
@@ -44,10 +45,22 @@
4445
# Initialize FastMCP server
4546
mcp = FastMCP(
4647
name=config.mcp_server_name,
47-
instructions=config.mcp_server_instructions,
48+
instructions=f'{config.mcp_server_instructions}\n\n{PARARAM_FORMATTING_GUIDE}',
4849
)
4950

5051

52+
@mcp.resource(
53+
'pararam://formatting',
54+
name='pararam_message_formatting',
55+
title='Pararam Message Formatting',
56+
description='Full Pararam message formatting reference for composing send_message and edit_post text.',
57+
mime_type='text/markdown',
58+
)
59+
def pararam_message_formatting() -> str:
60+
"""Return the full Pararam message formatting reference."""
61+
return PARARAM_FORMATTING_REFERENCE
62+
63+
5164
async def _prune_to_limited_tools(server: FastMCP[None]) -> list[str]:
5265
"""In limited mode, drop every registered tool not in the allow-list.
5366

packages/pararam-nexus-mcp/src/pararam_nexus_mcp/tools/posts.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,13 @@ async def send_message(
494494
"""
495495
Send a message to a chat.
496496
497+
Message formatting: Pararam supports Markdown-like text, but not Markdown headings.
498+
Use **bold** section titles instead. Use colors as [#RRGGBB](text);
499+
colored bullet example: [#2E7D32](●). Keep tables simple because colors
500+
may not render inside table cells. Use @all, @online, @admin, and @groups
501+
only when the user explicitly asks for broad notification; ask for explicit
502+
confirmation before sending such mentions. See pararam://formatting for full syntax.
503+
497504
Args:
498505
chat_id: ID of the chat to send message to
499506
text: Message text to send
@@ -1619,6 +1626,13 @@ async def edit_post(
16191626
) -> ToolResponse[EditPostPayload | None]:
16201627
"""Edit an existing post.
16211628
1629+
Message formatting: Pararam supports Markdown-like text, but not Markdown headings.
1630+
Use **bold** section titles instead. Use colors as [#RRGGBB](text);
1631+
colored bullet example: [#2E7D32](●). Keep tables simple because colors
1632+
may not render inside table cells. Use @all, @online, @admin, and @groups
1633+
only when the user explicitly asks for broad notification; ask for explicit
1634+
confirmation before sending such mentions. See pararam://formatting for full syntax.
1635+
16221636
Args:
16231637
chat_id: Numeric chat ID.
16241638
post_no: Post number to edit (must be authored by the token's user).
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,21 @@
11
"""Tests for server module."""
22

33
from pararam_nexus_mcp import __version__
4+
from pararam_nexus_mcp.formatting import PARARAM_FORMATTING_GUIDE, PARARAM_FORMATTING_REFERENCE
45

56

67
def test_version() -> None:
78
"""Test that version is set."""
89
assert isinstance(__version__, str)
910
assert len(__version__) > 0
11+
12+
13+
def test_pararam_formatting_guide_mentions_supported_markup() -> None:
14+
"""Test that the MCP guidance documents Pararam-specific formatting."""
15+
assert 'Markdown headings' in PARARAM_FORMATTING_GUIDE
16+
assert '**bold**' in PARARAM_FORMATTING_GUIDE
17+
assert '[#2E7D32](●)' in PARARAM_FORMATTING_GUIDE
18+
assert '@all' in PARARAM_FORMATTING_GUIDE
19+
assert 'only when the user explicitly asks' in PARARAM_FORMATTING_GUIDE
20+
assert 'ask the user for explicit confirmation' in PARARAM_FORMATTING_GUIDE
21+
assert '[ ](task text)' in PARARAM_FORMATTING_REFERENCE

0 commit comments

Comments
 (0)