Skip to content

Commit 34286cd

Browse files
committed
fix: 完善获取签名定位URL功能
1 parent 902491c commit 34286cd

29 files changed

Lines changed: 612 additions & 191 deletions

api/handler/api/common_service.go

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/mcp/academic.go

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,40 +29,48 @@ import (
2929

3030
func GetScoresTool() mcpgoserver.ServerTool {
3131
return mcpgoserver.ServerTool{
32-
Tool: mcp.NewTool("get_scores",
32+
Tool: mcp.NewTool(
33+
"get_scores",
3334
mcp.WithDescription(
3435
"Fetch the user's score records for a given academic term. "+
3536
"Use this when the user asks to view grades/scores for a specific term. "+
36-
"Returns the score list for the given term."),
37+
"Returns the score list for the given term.",
38+
),
3739
mcp.WithString("user_id",
3840
mcp.Required(),
3941
mcp.Description(
40-
"user_id data comes from the login method response (user_id field).")),
42+
"user_id data comes from the login method response (user_id field).",
43+
)),
4144
mcp.WithString("user_cookies",
4245
mcp.Required(),
4346
mcp.Description(
44-
"user_cookies data comes from the login method response (user_cookies field).")),
47+
"user_cookies data comes from the login method response (user_cookies field).",
48+
)),
4549
),
4650
Handler: handleGetScores,
4751
}
4852
}
4953

5054
func GetGPATool() mcpgoserver.ServerTool {
5155
return mcpgoserver.ServerTool{
52-
Tool: mcp.NewTool("get_gpa",
56+
Tool: mcp.NewTool(
57+
"get_gpa",
5358
mcp.WithDescription(
5459
"Fetch the user's GPA (Grade Point Average) information for a given academic term. "+
5560
"Use this when the user asks to view GPA or grade point information. "+
5661
"Returns the GPA data including overall and term-specific GPA. "+
57-
"Note: This feature is only available for undergraduate students. Graduate students should use get_scores instead."),
62+
"Note: This feature is only available for undergraduate students. Graduate students should use get_scores instead.",
63+
),
5864
mcp.WithString("user_id",
5965
mcp.Required(),
6066
mcp.Description(
61-
"user_id data comes from the login method response (user_id field).")),
67+
"user_id data comes from the login method response (user_id field).",
68+
)),
6269
mcp.WithString("user_cookies",
6370
mcp.Required(),
6471
mcp.Description(
65-
"user_cookies data comes from the login method response (user_cookies field).")),
72+
"user_cookies data comes from the login method response (user_cookies field).",
73+
)),
6674
),
6775
Handler: handleGetGPA,
6876
}

api/mcp/auth.go

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,25 @@ type IdentifierData struct {
3737

3838
func LoginTool() mcpgoserver.ServerTool {
3939
return mcpgoserver.ServerTool{
40-
Tool: mcp.NewTool("login",
40+
Tool: mcp.NewTool(
41+
"login",
4142
mcp.WithDescription("Use this tool when the user wants to log into the educational system. "+
4243
"Call this when: user mentions logging in, needs to authenticate, "+
4344
"or when other tools fail due to no active session. "+
4445
"If JWCH_STUDENT_ID and JWCH_PASSWORD environment variables are set, "+
4546
"this happens automatically on startup. Returns success message on successful login."),
46-
mcp.WithString("student_id",
47+
mcp.WithString(
48+
"student_id",
4749
mcp.Required(),
4850
mcp.Description("Student ID for authentication (optional if FZUHELPER_STUDENT_ID env var is set)"),
4951
),
50-
mcp.WithString("password",
52+
mcp.WithString(
53+
"password",
5154
mcp.Required(),
5255
mcp.Description("Password for authentication (optional if FZUHELPER_STUDENT_PASSWORD env var is set)"),
5356
),
54-
mcp.WithString("student_type",
57+
mcp.WithString(
58+
"student_type",
5559
mcp.Description("StudentType for authentication. Defaults to \"1\" (Undergraduate student). "+
5660
"Set \"2\" for Postgraduate(optional if FZUHELPER_STUDENT_TYPE env var is set)"),
5761
),
@@ -62,15 +66,18 @@ func LoginTool() mcpgoserver.ServerTool {
6266

6367
func CheckSessionTool() mcpgoserver.ServerTool {
6468
return mcpgoserver.ServerTool{
65-
Tool: mcp.NewTool("check_session",
69+
Tool: mcp.NewTool(
70+
"check_session",
6671
mcp.WithDescription("Use this tool to verify if the current login session is still valid. "+
6772
"Call this when: user asks about connection status, before performing operations after a long idle "+
6873
"period, or to troubleshoot authentication issues. Returns session validity status."),
69-
mcp.WithString("user_id",
74+
mcp.WithString(
75+
"user_id",
7076
mcp.Required(),
7177
mcp.Description("user_id data comes from login method response, (user_cookies field)"),
7278
),
73-
mcp.WithString("user_cookies",
79+
mcp.WithString(
80+
"user_cookies",
7481
mcp.Required(),
7582
mcp.Description("user_cookies data comes from login method response, (user_cookies field)"),
7683
),

api/mcp/calendar.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,24 @@ import (
2929

3030
func GetCalendarTool() mcpgoserver.ServerTool {
3131
return mcpgoserver.ServerTool{
32-
Tool: mcp.NewTool("get_calendar",
32+
Tool: mcp.NewTool(
33+
"get_calendar",
3334
mcp.WithDescription(
3435
"Fetch the academic calendar in ICS format for the current term. "+
3536
"Use this when the user asks to view the academic calendar, course schedule in calendar format, "+
3637
"or wants to import course schedule into calendar applications. "+
37-
"Returns the calendar data in ICS format (base64 encoded)."),
38+
"Returns the calendar data in ICS format (base64 encoded).",
39+
),
3840
mcp.WithString("user_id",
3941
mcp.Required(),
4042
mcp.Description(
41-
"user_id data comes from the login method response (user_id field).")),
43+
"user_id data comes from the login method response (user_id field).",
44+
)),
4245
mcp.WithString("user_cookies",
4346
mcp.Required(),
4447
mcp.Description(
45-
"user_cookies data comes from the login method response (user_cookies field).")),
48+
"user_cookies data comes from the login method response (user_cookies field).",
49+
)),
4650
),
4751
Handler: handleGetCalendar,
4852
}

api/mcp/classroom.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,24 +29,29 @@ import (
2929

3030
func GetExamRoomTool() mcpgoserver.ServerTool {
3131
return mcpgoserver.ServerTool{
32-
Tool: mcp.NewTool("get_exam_room",
32+
Tool: mcp.NewTool(
33+
"get_exam_room",
3334
mcp.WithDescription(
3435
"Fetch the user's exam room information and schedule. "+
3536
"Use this when the user asks to view exam locations, exam schedule, or examination room details. "+
36-
"Returns exam room information including location, time, seat number, and course details."),
37+
"Returns exam room information including location, time, seat number, and course details.",
38+
),
3739
mcp.WithString("user_id",
3840
mcp.Required(),
3941
mcp.Description(
40-
"user_id data comes from the login method response (user_id field).")),
42+
"user_id data comes from the login method response (user_id field).",
43+
)),
4144
mcp.WithString("user_cookies",
4245
mcp.Required(),
4346
mcp.Description(
44-
"user_cookies data comes from the login method response (user_cookies field).")),
47+
"user_cookies data comes from the login method response (user_cookies field).",
48+
)),
4549
mcp.WithString("term",
4650
mcp.Description(
4751
"Academic term code in the form yyyymm. "+
4852
"Examples: 202401 means 2024 Autumn term, 202402 means 2025 Spring term. "+
49-
"Optional: defaults to current term")),
53+
"Optional: defaults to current term",
54+
)),
5055
),
5156
Handler: handleGetExamRoom,
5257
}

api/mcp/course.go

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,38 +32,45 @@ import (
3232

3333
func GetCourseTool() mcpgoserver.ServerTool {
3434
return mcpgoserver.ServerTool{
35-
Tool: mcp.NewTool("get_course_list",
35+
Tool: mcp.NewTool(
36+
"get_course_list",
3637
mcp.WithDescription(
3738
"Fetch the user's course list for a given academic term. "+
3839
"ALWAYS call get_date first to determine the current term and week if the user asks about today's timetable or current-week schedule. "+
3940
"Do NOT guess dates or terms—use get_date to retrieve them. "+
4041
"Use this when the user asks to view courses/timetable for a specific term or the current day/week. "+
41-
"Returns the course list for the given term."),
42+
"Returns the course list for the given term.",
43+
),
4244
mcp.WithString("term",
4345
mcp.Description(
4446
"Academic term code in the form yyyymm. "+
4547
"Examples: 202401 means 2024 Autumn term, 202402 means 2025 Spring term. "+
46-
"If omitted, the tool will use get_date-derived current term automatically.")),
48+
"If omitted, the tool will use get_date-derived current term automatically.",
49+
)),
4750
mcp.WithString("user_id",
4851
mcp.Required(),
4952
mcp.Description(
50-
"user_id data comes from the login method response (user_id field).")),
53+
"user_id data comes from the login method response (user_id field).",
54+
)),
5155
mcp.WithString("user_cookies",
5256
mcp.Required(),
5357
mcp.Description(
54-
"user_cookies data comes from the login method response (user_cookies field).")),
58+
"user_cookies data comes from the login method response (user_cookies field).",
59+
)),
5560
),
5661
Handler: handleGetCourse,
5762
}
5863
}
5964

6065
func GetDateTool() mcpgoserver.ServerTool {
6166
return mcpgoserver.ServerTool{
62-
Tool: mcp.NewTool("get_date",
67+
Tool: mcp.NewTool(
68+
"get_date",
6369
mcp.WithDescription(
6470
"Get the current year, academic term, week number, calendar date, and weekday. "+
6571
"You MUST call this before attempting to fetch today's timetable or current-week schedule. "+
66-
"Returns: year, term, week, date (YYYY-MM-DD), term_formatted, weekday_name (e.g., Monday), weekday_number (1-7)."),
72+
"Returns: year, term, week, date (YYYY-MM-DD), term_formatted, weekday_name (e.g., Monday), weekday_number (1-7).",
73+
),
6774
),
6875
Handler: handleGetDate,
6976
}

api/mcp/mcp.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ func CreateMCPProxy() *Proxy {
3838
// mcpgoserver.WithLogger(logger.Logger) // TODO: 引入我们自己的 logger
3939
)
4040

41-
server.AddTools(LoginTool(), CheckSessionTool(),
41+
server.AddTools(
42+
LoginTool(), CheckSessionTool(),
4243
GetCourseTool(),
4344
GetDateTool(),
4445
GetScoresTool(),

api/mcp/notice.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,21 @@ const defaultNoticePageSize = 10
3030

3131
func GetNoticesTool() mcpgoserver.ServerTool {
3232
return mcpgoserver.ServerTool{
33-
Tool: mcp.NewTool("get_notices",
33+
Tool: mcp.NewTool(
34+
"get_notices",
3435
mcp.WithDescription(
3536
"Fetch notices and announcements from the educational administration office. "+
3637
"Use this when the user asks to view official notices, announcements, or news from the academic affairs office. "+
37-
"Returns a list of notices with pagination support. No login required."),
38+
"Returns a list of notices with pagination support. No login required.",
39+
),
3840
mcp.WithNumber("page",
3941
mcp.Description(
40-
"Page number for pagination. Optional: defaults to 1")),
42+
"Page number for pagination. Optional: defaults to 1",
43+
)),
4144
mcp.WithNumber("page_size",
4245
mcp.Description(
43-
"Number of notices per page. Optional: defaults to 10")),
46+
"Number of notices per page. Optional: defaults to 10",
47+
)),
4448
),
4549
Handler: handleGetNotices,
4650
}

api/mcp/user.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,23 @@ import (
2828

2929
func GetUserInfoTool() mcpgoserver.ServerTool {
3030
return mcpgoserver.ServerTool{
31-
Tool: mcp.NewTool("get_user_info",
31+
Tool: mcp.NewTool(
32+
"get_user_info",
3233
mcp.WithDescription(
3334
"Fetch the user's personal information from the educational system. "+
3435
"Use this when the user asks to view their profile, personal details, or student information. "+
35-
"Returns user information including name, student ID, major, and other personal details."),
36+
"Returns user information including name, student ID, major, and other personal details.",
37+
),
3638
mcp.WithString("user_id",
3739
mcp.Required(),
3840
mcp.Description(
39-
"user_id data comes from the login method response (user_id field).")),
41+
"user_id data comes from the login method response (user_id field).",
42+
)),
4043
mcp.WithString("user_cookies",
4144
mcp.Required(),
4245
mcp.Description(
43-
"user_cookies data comes from the login method response (user_cookies field).")),
46+
"user_cookies data comes from the login method response (user_cookies field).",
47+
)),
4448
),
4549
Handler: handleGetUserInfo,
4650
}

api/model/api/api.go

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)